Skip to content

Conversation

@Retrospection
Copy link
Contributor

Summary

This PR adds support for additional layers to the Java bindings to align with Python and Node.js bindings.

Added Layers

  • MimeGuessLayer: Automatically set Content-Type based on file extension
  • TimeoutLayer: Add timeout for operations (both IO and non-IO)
  • LoggingLayer: Add structured logging for all operations
  • HotpathLayer: Add hotpath profiling for performance analysis

Changes

  • Added 4 new Java layer classes in bindings/java/src/main/java/org/apache/opendal/layer/
  • Added corresponding JNI implementations in bindings/java/src/layer.rs
  • Updated bindings/java/Cargo.toml to enable required features
  • Added tests in bindings/java/src/test/java/org/apache/opendal/test/LayerTest.java

Testing

All 7 layer tests pass:

  • testOperatorWithRetryLayer
  • testOperatorWithConcurrentLimitLayer
  • testOperatorWithMimeGuessLayer
  • testOperatorWithTimeoutLayer
  • testOperatorWithLoggingLayer
  • testOperatorWithThrottleLayer
  • testOperatorWithHotpathLayer

Issue

Closes #6738

This commit adds support for additional layers to the Java bindings:
- MimeGuessLayer: automatically set Content-Type based on file extension
- TimeoutLayer: add timeout for operations
- LoggingLayer: add structured logging for operations
- HotpathLayer: add hotpath profiling for operations

These layers were already supported in Python and Node.js bindings but were missing in Java, causing API inconsistency across language bindings.

Closes apache#6738
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. releases-note/feat The PR implements a new feature or has a title that begins with "feat" labels Jan 2, 2026
@Retrospection Retrospection requested a review from Xuanwo as a code owner January 2, 2026 05:36
This commit fixes Java code formatting issues detected by spotless.
@PsiACE
Copy link
Member

PsiACE commented Jan 2, 2026

for toml format , u can use taplo to fix it

@Retrospection Retrospection changed the title [java] Add additional layers support feat: add additional layers support Jan 2, 2026
@Retrospection Retrospection force-pushed the java-additional-layers branch 2 times, most recently from 753383a to 05fddba Compare January 2, 2026 11:46
@Retrospection Retrospection requested a review from Xuanwo January 2, 2026 15:06
/**
* This layer adds structured logging for every operation.
*
* <p>Note: This layer requires proper logging setup (e.g., log4j2, java.util.logging) to work.
Copy link
Member

Choose a reason for hiding this comment

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

Hi, please understand your changes first. LoggingLayer integrate rust's log crate and thus requires we to provide a set_logger call. Users can't configure that through log4j2 or java.util.logging.

Maybe we can start a discussion thread on how we do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for rough pr.

Honestly I'm not that familiar with this binding layer, and just think this can be implemented with ai just because it has other language implementation as reference.

I'll do some research to understand what the binding layer is for and then do discussion about implementation.

Thanks for kindly review.

@Retrospection Retrospection marked this pull request as draft January 7, 2026 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

releases-note/feat The PR implements a new feature or has a title that begins with "feat" size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

new feature: Add all layers in Java binding

3 participants