File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
superstream-clients/src/main/java/ai/superstream/agent Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -132,12 +132,23 @@ public static void onEnter(@Advice.AllArguments Object[] args) {
132132 boolean immutableConfigDetected = false ;
133133 java .util .Map <String ,Object > immutableOriginalMap = null ;
134134 for (Object arg : args ) {
135- if (arg instanceof java .util .Map && arg .getClass ().getName ().contains ("UnmodifiableMap" )) {
136- immutableConfigDetected = true ;
135+ if (arg instanceof java .util .Map ) {
137136 @ SuppressWarnings ("unchecked" )
138- java .util .Map <String ,Object > tmp = (java .util .Map <String ,Object >) arg ;
139- immutableOriginalMap = tmp ;
140- break ;
137+ java .util .Map <String ,Object > testMap = (java .util .Map <String ,Object >) arg ;
138+
139+ // Skip empty maps as they might be immutable but don't matter for optimization
140+ if (!testMap .isEmpty ()) {
141+ try {
142+ String testKey = "__superstream_immutable_test_" + System .nanoTime ();
143+ testMap .put (testKey , "test" );
144+ testMap .remove (testKey );
145+ } catch (UnsupportedOperationException | IllegalStateException e ) {
146+ // Map is immutable
147+ immutableConfigDetected = true ;
148+ immutableOriginalMap = testMap ;
149+ break ;
150+ }
151+ }
141152 }
142153 }
143154
You can’t perform that action at this time.
0 commit comments