-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix anonymous class serialization warnings
Anonymous inner classes are replaced by a dedicated comparator class. NOTE: Also introducing classes to keep XStream backward compatibility. This was missed in the previous attempt in commit 2366eae. The warnings from org.jenkinsci.remoting.util.AnonymousClassWarnings have been: > "Attempt to (de-)serialize anonymous class org.jenkinsci.plugins.configfiles.GlobalConfigFiles$1 ..." > "Attempt to (de-)serialize anonymous class org.jenkinsci.plugins.configfiles.folder.FolderConfigFileProperty$1 ..." see: https://wiki.jenkins.io/display/JENKINS/Serialization+of+anonymous+classes
- Loading branch information
Showing
5 changed files
with
54 additions
and
13 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
src/main/java/org/jenkinsci/plugins/configfiles/ConfigByIdComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.jenkinsci.plugins.configfiles; | ||
|
||
import org.jenkinsci.lib.configprovider.model.Config; | ||
|
||
import java.io.Serializable; | ||
import java.util.Comparator; | ||
|
||
public class ConfigByIdComparator implements Comparator<Config>, Serializable { | ||
|
||
@Override | ||
public int compare(Config c1, Config c2) { | ||
return c1.id.compareTo(c2.id); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/org/jenkinsci/plugins/configfiles/GlobalConfigFiles$1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.jenkinsci.plugins.configfiles; | ||
|
||
import org.kohsuke.accmod.Restricted; | ||
import org.kohsuke.accmod.restrictions.DoNotUse; | ||
|
||
/** | ||
* This class is required for XStream backward compatibility because {@link GlobalConfigFiles} | ||
* formerly contained an anonymous inner class defining the comparator. | ||
* | ||
* For old XML configurations that still contain a comparator element as follows | ||
* {@code <comparator class="org.jenkinsci.plugins.configfiles.GlobalConfigFiles$1"/>} | ||
* XStream tries to resolve a class named exactly like this during deserialization. | ||
* | ||
* @deprecated replaced by {@link ConfigByIdComparator} | ||
*/ | ||
@Deprecated | ||
@Restricted(DoNotUse.class) | ||
final class GlobalConfigFiles$1 extends ConfigByIdComparator {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/java/org/jenkinsci/plugins/configfiles/folder/FolderConfigFileProperty$1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.jenkinsci.plugins.configfiles.folder; | ||
|
||
import org.jenkinsci.plugins.configfiles.ConfigByIdComparator; | ||
import org.kohsuke.accmod.Restricted; | ||
import org.kohsuke.accmod.restrictions.DoNotUse; | ||
|
||
/** | ||
* This class is required for XStream backward compatibility because {@link FolderConfigFileProperty} | ||
* formerly contained an anonymous inner class defining the comparator. | ||
* | ||
* For old XML configurations that still contain a comparator element as follows | ||
* {@code <comparator class="org.jenkinsci.plugins.configfiles.folder.FolderConfigFileProperty$1"/>} | ||
* XStream tries to resolve a class named exactly like this during deserialization. | ||
* | ||
* @deprecated replaced by {@link ConfigByIdComparator} | ||
*/ | ||
@Deprecated | ||
@Restricted(DoNotUse.class) | ||
final class FolderConfigFileProperty$1 extends ConfigByIdComparator {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters