Skip to content

Commit bf8d507

Browse files
committed
Reuse noInstanceBecauseStaticField for getting the existing methods
1 parent 0d97d8f commit bf8d507

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

api/src/main/java/com/messagebird/MessageBirdServiceImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,13 @@ private synchronized static void allowPatchRequestsIfNeeded() throws GeneralExce
257257
modifiersField.setAccessible(true);
258258
modifiersField.setInt(methodsField, methodsField.getModifiers() & ~Modifier.FINAL);
259259

260+
Object noInstanceBecauseStaticField = null;
261+
260262
// Determine what methods should be allowed.
261-
String[] allowedMethods = getAllowedMethods((String[]) methodsField.get(null));
263+
String[] existingMethods = (String[]) methodsField.get(noInstanceBecauseStaticField);
264+
String[] allowedMethods = getAllowedMethods(existingMethods);
262265

263266
// Override the actual field to allow PATCH.
264-
Object noInstanceBecauseStaticField = null;
265267
methodsField.set(noInstanceBecauseStaticField, allowedMethods);
266268

267269
// Set flag so we only have to run this once.

0 commit comments

Comments
 (0)