forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid XStream causing illegal access issues for internal JDK collections
Relates to: quarkusio#24492
- Loading branch information
Showing
3 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
test-framework/junit5/src/main/java/io/quarkus/test/junit/internal/CustomListConverter.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,32 @@ | ||
package io.quarkus.test.junit.internal; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.thoughtworks.xstream.converters.collections.CollectionConverter; | ||
import com.thoughtworks.xstream.mapper.Mapper; | ||
|
||
/** | ||
* A custom List converter that always uses ArrayList for unmarshalling. | ||
* This is probably not semantically correct 100% of the time, but it's likely fine | ||
* for all the cases where we are using marshalling / unmarshalling. | ||
* | ||
* The reason for doing this is to avoid XStream causing illegal access issues | ||
* for internal JDK lists | ||
*/ | ||
public class CustomListConverter extends CollectionConverter { | ||
|
||
public CustomListConverter(Mapper mapper) { | ||
super(mapper); | ||
} | ||
|
||
@Override | ||
public boolean canConvert(Class type) { | ||
return List.class.isAssignableFrom(type); | ||
} | ||
|
||
@Override | ||
protected Object createCollection(Class type) { | ||
return new ArrayList<>(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
test-framework/junit5/src/main/java/io/quarkus/test/junit/internal/CustomSetConverter.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,32 @@ | ||
package io.quarkus.test.junit.internal; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import com.thoughtworks.xstream.converters.collections.CollectionConverter; | ||
import com.thoughtworks.xstream.mapper.Mapper; | ||
|
||
/** | ||
* A custom Set converter that always uses HashSet for unmarshalling. | ||
* This is probably not semantically correct 100% of the time, but it's likely fine | ||
* for all the cases where we are using marshalling / unmarshalling. | ||
* | ||
* The reason for doing this is to avoid XStream causing illegal access issues | ||
* for internal JDK sets | ||
*/ | ||
public class CustomSetConverter extends CollectionConverter { | ||
|
||
public CustomSetConverter(Mapper mapper) { | ||
super(mapper); | ||
} | ||
|
||
@Override | ||
public boolean canConvert(Class type) { | ||
return Set.class.isAssignableFrom(type); | ||
} | ||
|
||
@Override | ||
protected Object createCollection(Class type) { | ||
return new HashSet<>(); | ||
} | ||
} |
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