Skip to content

[Java] Fix NoClassDefFoundError: lombok/Lombok at runtime#514

Open
jvdadda wants to merge 2 commits intoawslabs:masterfrom
mobsuccess-devops:fix/remove-sneakythrows-runtime-dep
Open

[Java] Fix NoClassDefFoundError: lombok/Lombok at runtime#514
jvdadda wants to merge 2 commits intoawslabs:masterfrom
mobsuccess-devops:fix/remove-sneakythrows-runtime-dep

Conversation

@jvdadda
Copy link
Copy Markdown

@jvdadda jvdadda commented Mar 10, 2026

Summary

Fixes #513@SneakyThrows generates bytecode that calls Lombok.sneakyThrow() at runtime, but Lombok is declared with scope: provided and is not present in the runtime classpath. This causes NoClassDefFoundError: lombok/Lombok when any checked exception is thrown in a @SneakyThrows-annotated method.

Changes

Replaced all @SneakyThrows usages in production code (7 files across 4 modules) with explicit try-catch blocks:

  • serializer-deserializer: GlueSchemaRegistrySerializationFacade, AvroSerializer, GlueSchemaRegistryDeserializerDataParser
  • common: SchemaByDefinitionFetcher
  • avro-flink-serde: GlueSchemaRegistryAvroSerializationSchema
  • protobuf-kafkaconnect-converter: ProtobufDataToConnectDataConverter, ConnectSchemaToProtobufSchemaConverter

Checked exceptions are wrapped in the appropriate runtime exception for each context (AWSSchemaRegistryException, UncheckedIOException, DataException).

@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
Copilot AI review requested due to automatic review settings March 10, 2026 14:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 @SneakyThrows from 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Version 1.1.27 causes NoClassDefFoundError: lombok/Lombok at runtime during schema serialization

3 participants