Skip to content

Commit 0968905

Browse files
author
Jiří Pejchal
committed
DWR-660 retain member order in generated scripts between runs
- sort method names inside dwr interfaces so that content doesn't change between application runs - allows consistent content hashing
1 parent c1d9375 commit 0968905

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

core/impl/main/java/org/directwebremoting/impl/DefaultRemoter.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package org.directwebremoting.impl;
22

33
import java.lang.reflect.InvocationTargetException;
4+
import java.util.Arrays;
5+
import java.util.Comparator;
46
import java.util.Map;
57
import java.util.Map.Entry;
68

@@ -64,6 +66,18 @@ public String generateInterfaceJavaScript(String scriptName, String indent, Stri
6466
Module module = moduleManager.getModule(scriptName, false);
6567

6668
MethodDeclaration[] methods = module.getMethods();
69+
Arrays.sort(methods, new Comparator<MethodDeclaration>()
70+
{
71+
@Override
72+
public int compare(MethodDeclaration m1, MethodDeclaration m2)
73+
{
74+
int i = m1.getName().compareTo(m2.getName());
75+
if (i != 0) {
76+
return i;
77+
}
78+
return Integer.compare(m1.getParameterTypes().length, m2.getParameterTypes().length);
79+
}
80+
});
6781
for (MethodDeclaration method : methods)
6882
{
6983
String methodName = method.getName();

0 commit comments

Comments
 (0)