Skip to content

Commit

Permalink
Prevent class cast exception on returnedClass()
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Jan 1, 2025
1 parent 1a6f87d commit c71d9f7
Show file tree
Hide file tree
Showing 2 changed files with 328 additions and 150 deletions.
6 changes: 5 additions & 1 deletion src/main/java/org/openrewrite/hibernate/MigrateUserType.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, At

@Override
public J.Return visitReturn(J.Return _return, AtomicReference<J.FieldAccess> ref) {
ref.set((J.FieldAccess) _return.getExpression());
Expression expression = _return.getExpression();
if (expression instanceof J.FieldAccess &&
"class".equals(((J.FieldAccess) expression).getSimpleName())) {
ref.set((J.FieldAccess) expression);
}
return _return;
}
}.visitNonNull(cd, reference);
Expand Down
Loading

0 comments on commit c71d9f7

Please sign in to comment.