@@ -34,7 +34,6 @@ public abstract class PatchSetPatcher implements Patcher {
34
34
private Instrumentation instrumentation ;
35
35
private Logger logger ;
36
36
private ClassFileTransformer transformer ;
37
- private List <ClassTransformerHotPatch > enabledPatches ;
38
37
39
38
protected abstract List <ClassTransformerHotPatch > getPatches ();
40
39
@@ -44,8 +43,7 @@ public int install(final Map<String, String> args, final int asmApiVersion, fina
44
43
this .instrumentation = instrumentation ;
45
44
this .logger = logger ;
46
45
47
- this .enabledPatches = getEnabledPatches (args );
48
- this .transformer = new PatchSetTransformer (enabledPatches , asmApiVersion , logger );
46
+ this .transformer = new PatchSetTransformer (getPatches (), asmApiVersion , logger );
49
47
50
48
if (staticAgent ) {
51
49
// As we are being installed during startup, we don't care about retransforming. The transformer will
@@ -59,7 +57,7 @@ public int install(final Map<String, String> args, final int asmApiVersion, fina
59
57
boolean patchesApplied = false ;
60
58
for (Class <?> c : instrumentation .getAllLoadedClasses ()) {
61
59
String className = c .getName ();
62
- for (ClassTransformerHotPatch patch : enabledPatches ) {
60
+ for (ClassTransformerHotPatch patch : getPatches () ) {
63
61
if (patch .isTargetClass (className )) {
64
62
logger .log ("Patching + " + className + " (" + c .getClassLoader () + ") with patch "
65
63
+ patch .getName ());
@@ -90,7 +88,7 @@ public int uninstall() {
90
88
// Retransform after we've removed the transformer to restore the initial class versions.
91
89
for (Class <?> c : instrumentation .getAllLoadedClasses ()) {
92
90
String className = c .getName ();
93
- for (ClassTransformerHotPatch patch : enabledPatches ) {
91
+ for (ClassTransformerHotPatch patch : getPatches () ) {
94
92
if (patch .isTargetClass (className )) {
95
93
logger .log ("Un-Patching " + c + " (" + c .getClassLoader () + ") of " + patch .getName ());
96
94
try {
@@ -124,29 +122,6 @@ public String getFullDescription() {
124
122
return sb .toString ();
125
123
}
126
124
127
- /**
128
- * Filters the result of getPatches based on the agent arguments. This is because besides what patches are defined
129
- * in a patch set, some of them can be disabled via command line arguments ,
130
- * @param args String with the arguments that was received by the agent,
131
- * @return A list with all the patches that are enabled,
132
- */
133
- private List <ClassTransformerHotPatch > getEnabledPatches (final Map <String , String > args ) {
134
- if (args == null ) {
135
- return getPatches ();
136
- }
137
- List <ClassTransformerHotPatch > enabledPatches = new ArrayList <>();
138
- outer : for (ClassTransformerHotPatch patch : getPatches ()) {
139
- for (String key : args .keySet ()) {
140
- if (key .equals ("disable-" + patch .getName ())) {
141
- // Do not add the current patch to the list of patches to apply
142
- continue outer ;
143
- }
144
- }
145
- enabledPatches .add (patch );
146
- }
147
- return enabledPatches ;
148
- }
149
-
150
125
private static class PatchSetTransformer implements ClassFileTransformer {
151
126
private final Logger logger ;
152
127
private final int asmApiVersion ;
0 commit comments