Skip to content

Commit 5b04d6e

Browse files
authored
#3551 Log warning for use of mapping column to Class (#3698)
I think it was a mistake for Ebean to support Class<?> from a security perspective. Instead, Ebean should just use a String <-> Varchar and leave if up to the application to take that String and convert it to a class [and then that potential Class initialisation is owned by the application code and all security considerations around that are owned by the application code].
1 parent d554780 commit 5b04d6e

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ public ScalarType<?> type(Class<?> type) {
216216
}
217217
found = checkInheritedTypes(type);
218218
}
219+
if (found instanceof ScalarTypeClass) {
220+
log.log(WARNING, "@Column mapping for type Class is deprecated. Please refer to https://ebean.io/docs/deprecated#class-mapping");
221+
}
219222
return found != ScalarTypeNotFound.INSTANCE ? found : null; // Do not return ScalarTypeNotFound, otherwise checks will fail
220223
}
221224

ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeClass.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
@SuppressWarnings({"rawtypes"})
1111
final class ScalarTypeClass extends ScalarTypeBaseVarchar<Class> {
1212

13-
public ScalarTypeClass() {
13+
ScalarTypeClass() {
1414
super(Class.class);
1515
}
1616

0 commit comments

Comments
 (0)