Skip to content

Commit

Permalink
fix: synchronize Model#of
Browse files Browse the repository at this point in the history
  • Loading branch information
teletha committed Aug 17, 2024
1 parent 646f946 commit 271b095
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/main/java/kiss/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public static <M> Model<M> of(M modelType) {
* @throws NullPointerException If the given model class is null.
* @throws IllegalArgumentException If the given model class is not found.
*/
public static <M> Model<M> of(Class<? super M> modelClass) {
public static synchronized <M> Model<M> of(Class<? super M> modelClass) {
<Class, Type[]> key = I.pair(modelClass, new Type[0]);

// check cache
Expand All @@ -380,7 +380,6 @@ public static <M> Model<M> of(Class<? super M> modelClass) {
model = models.computeIfAbsent(key, x -> new Model(modelClass));
model.init();
}
models.put(key, model);
}
return model;
}
Expand All @@ -395,7 +394,7 @@ public static <M> Model<M> of(Class<? super M> modelClass) {
* @throws IllegalArgumentException If the given model type is null.
* @see TypeVariable
*/
static Model of(Type type, Type base) {
static synchronized Model of(Type type, Type base) {
// class
if (type instanceof Class) {
return of((Class) type);
Expand Down

0 comments on commit 271b095

Please sign in to comment.