[Java] Fix NoClassDefFoundError: lombok/Lombok at runtime#514
Open
jvdadda wants to merge 2 commits intoawslabs:masterfrom
Open
[Java] Fix NoClassDefFoundError: lombok/Lombok at runtime#514jvdadda wants to merge 2 commits intoawslabs:masterfrom
jvdadda wants to merge 2 commits intoawslabs:masterfrom
Conversation
@SneakyThrows generates code that calls Lombok.sneakyThrow() at runtime, but Lombok is declared with scope 'provided' and not available at runtime. This causes NoClassDefFoundError: lombok/Lombok when exceptions are thrown. Replace @SneakyThrows with explicit try-catch blocks that wrap checked exceptions in appropriate runtime exceptions (AWSSchemaRegistryException, UncheckedIOException, DataException) depending on the module context. Fixes awslabs#513
There was a problem hiding this comment.
Pull request overview
Fixes a runtime NoClassDefFoundError: lombok/Lombok by removing Lombok @SneakyThrows from production code paths that could emit bytecode calling Lombok.sneakyThrow() at runtime (while Lombok is provided and absent from runtime classpaths).
Changes:
- Removed
@SneakyThrowsfrom serialization/deserialization and converter code paths. - Replaced implicit sneaky-throws behavior with explicit exception handling and runtime exception wrapping (e.g.,
AWSSchemaRegistryException,DataException,UncheckedIOException). - Added targeted exception handling around Avro/Flink serialization and Protobuf conversion operations.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| serializer-deserializer/src/main/java/com/amazonaws/services/schemaregistry/serializers/avro/AvroSerializer.java | Replaces @SneakyThrows on cache lookups with explicit try/catch and runtime wrapping. |
| serializer-deserializer/src/main/java/com/amazonaws/services/schemaregistry/serializers/GlueSchemaRegistrySerializationFacade.java | Removes @SneakyThrows annotation from schema version lookup entrypoint. |
| serializer-deserializer/src/main/java/com/amazonaws/services/schemaregistry/deserializers/GlueSchemaRegistryDeserializerDataParser.java | Replaces @SneakyThrows in decompression path with explicit handling and runtime wrapping. |
| protobuf-kafkaconnect-converter/src/main/java/com/amazonaws/services/schemaregistry/kafkaconnect/protobuf/toconnectdata/ProtobufDataToConnectDataConverter.java | Removes @SneakyThrows by catching protobuf parsing exceptions and rethrowing DataException. |
| protobuf-kafkaconnect-converter/src/main/java/com/amazonaws/services/schemaregistry/kafkaconnect/protobuf/fromconnectschema/ConnectSchemaToProtobufSchemaConverter.java | Replaces @SneakyThrows with explicit DescriptorValidationException handling via DataException. |
| avro-flink-serde/src/main/java/com/amazonaws/services/schemaregistry/flink/avro/GlueSchemaRegistryAvroSerializationSchema.java | Replaces @SneakyThrows with IOException handling and UncheckedIOException wrapping during serialization. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
LoadingCache.get() wraps loader failures in ExecutionException. Catching it specifically and using e.getCause() avoids double-wrapping and lets callers see the real failure reason.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #513 —
@SneakyThrowsgenerates bytecode that callsLombok.sneakyThrow()at runtime, but Lombok is declared withscope: providedand is not present in the runtime classpath. This causesNoClassDefFoundError: lombok/Lombokwhen any checked exception is thrown in a@SneakyThrows-annotated method.Changes
Replaced all
@SneakyThrowsusages in production code (7 files across 4 modules) with explicit try-catch blocks:GlueSchemaRegistrySerializationFacade,AvroSerializer,GlueSchemaRegistryDeserializerDataParserSchemaByDefinitionFetcherGlueSchemaRegistryAvroSerializationSchemaProtobufDataToConnectDataConverter,ConnectSchemaToProtobufSchemaConverterChecked exceptions are wrapped in the appropriate runtime exception for each context (
AWSSchemaRegistryException,UncheckedIOException,DataException).