Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to extend SentryHandler in JUL for configuration in Payara/Glassfish #1360

Closed
24 tasks
davyrod opened this issue Mar 29, 2021 · 4 comments · Fixed by #1367
Closed
24 tasks

Unable to extend SentryHandler in JUL for configuration in Payara/Glassfish #1360

davyrod opened this issue Mar 29, 2021 · 4 comments · Fixed by #1367
Labels
enhancement New feature or request JUL

Comments

@davyrod
Copy link
Contributor

davyrod commented Mar 29, 2021

Platform:

  • Android -> If yes, which Device API (and compileSdkVersion/targetSdkVersion/Build tools) version?
  • [ X ] Java -> If yes, which Java (and sourceCompatibility/targetCompatibility) version? Azul JDK 1.8
  • Kotlin -> If yes, which Kotlin (and jvmTarget) version?
  • NDK -> If yes, which NDK/CMake version?
  • React-Native -> If yes, which version?
  • Timber -> If yes, which version?
  • Log4j2 -> If yes, which version?
  • Logback -> If yes, which version?
  • Spring -> If yes, which version?

IDE:

  • Android Studio -> If yes, which version?
  • IntelliJ -> If yes, which version?
  • Other -> If yes, which one?

Build system:

  • Gradle -> If yes, which version?
  • Buck -> If yes, which version?
  • Bazel -> If yes, which version?
  • [ X ] Maven -> If yes, which version?
  • Other -> If yes, which one?

Android Gradle Plugin:

  • Yes -> If yes, which version?
  • No

Sentry Android Gradle Plugin:

  • Yes -> If yes, which version?
  • No

Proguard/R8:

  • Enabled
  • Disabled

Platform installed with:

  • JCenter
  • Bintray
  • [ X ] Maven Central
  • Manually

The version of the SDK:
4.x.x


I have the following issue:

The description goes here
sentry-jul SentryHandler was added back in 4.x.x, however I am unable to extend the class in order to configure the sentry loghandler as a custom loghandler in an application deployed using Payara/Glassfish. The reason seems to be related to the class being marked as 'final'. Is there a reason for the 'final' identifier, and if not, can it be removed to allow extension? If it is not possible, what is a good workaround for extending and deploying to an application in Payara/Glassfish?

Steps to reproduce:

  • Try to extend SentryHandler class in custom handler

`import java.util.logging.Handler;
import io.sentry.jul.SentryHandler;

import javax.inject.Singleton;

import org.jvnet.hk2.annotations.ContractsProvided;
import org.jvnet.hk2.annotations.Service;

@service
@singleton
@ContractsProvided({PayaraSentryHandler.class, Handler.class})
public class PayaraSentryHandler extends SentryHandler {
}`

Actual result:

  • Compile error: The type PayaraSentryHandler cannot subclass the final class SentryHandler

Expected result:

  • Successful extension of SentryHandler class
@marandaneto marandaneto added enhancement New feature or request JUL labels Mar 30, 2021
@marandaneto
Copy link
Contributor

@davyrod thanks for reporting, why would you need to extend, what's the use case? if that makes sense, we could also implement it directly to SentryHandler

the reason for making everything if possible as non-extendable is:

Design and document for inheritance or else prohibit it

@davyrod
Copy link
Contributor Author

davyrod commented Mar 30, 2021

In enterprise application servers like Glassfish/Payara (we use Payara), the log handlers are managed by the application server. In order to add additional LogHandlers an HK2 component needs to be created so Payara can register the additional log handler service, in this case Sentry.

We currently have a working sentry log handler on v1.7.30 by extending SentryHandler and are trying to upgrade to sentry-jul 4.3.0 with the above mentioned blocker. Here is a reference to an example of how we currently use Sentry in a Payara server deployment: Payara Sentry Log Handler Example v1.7.30

@marandaneto
Copy link
Contributor

@davyrod I see, that makes sense, thanks for explaining.

would you like to contribute with a PR? make it non-final but add the @OPEN annotation :)

@davyrod
Copy link
Contributor Author

davyrod commented Mar 30, 2021

@marandaneto PR submitted and checks passed.

marandaneto added a commit to davyrod/sentry-java that referenced this issue Mar 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request JUL
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants