Giter Club home page Giter Club logo

Comments (2)

andrewazores avatar andrewazores commented on June 24, 2024 1

For that specific example I think creating something like a ProbeDefinitionException class would make sense, and then just wrap the implementation with a try/catch that catches all those other types of exception and wraps them into a ProbeDefinitionException. In other places just replacing the throws clause on the method with an expanded list of the checked exception types is probably more suitable, it'll just have to be decided on a case-by-case basis.

from cryostat-core.

maxcao13 avatar maxcao13 commented on June 24, 2024

Seems like the update is causing a lot of new THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION / RUNTIME spotbugs errors https://spotbugs.readthedocs.io/en/stable/bugDescriptions.html#throws-method-lists-exception-in-its-throws-clause-throws-method-throws-clause-basic-exception. Around 35-40 in -core. Other repos in other orgs have issues with false positives with Junit 5 AssertThrowables and other issues, but I don't think we have that here.
e.g.

INFO] BugInstance size is 43
[INFO] Error size is 0
[INFO] Total bugs: 43
[ERROR] Medium: io.cryostat.core.agent.AgentJMXHelper.getMBeanServerConnection() may expose internal representation by returning AgentJMXHelper.mbsc [io.cryostat.core.agent.AgentJMXHelper] At AgentJMXHelper.java:[line 73] EI_EXPOSE_REP
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.agent.AgentJMXHelper] At AgentJMXHelper.java:[lines 118-125] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.agent.AgentJMXHelper] At AgentJMXHelper.java:[lines 78-81] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.agent.AgentJMXHelper] At AgentJMXHelper.java:[lines 103-112] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.agent.AgentJMXHelper] At AgentJMXHelper.java:[lines 87-97] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: new io.cryostat.core.agent.LocalProbeTemplateService(FileSystem, Environment) may expose internal representation by storing an externally mutable object into LocalProbeTemplateService.fs [io.cryostat.core.agent.LocalProbeTemplateService] At LocalProbeTemplateService.java:[line 64] EI_EXPOSE_REP2
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.agent.LocalProbeTemplateService] At LocalProbeTemplateService.java:[lines 89-105] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.agent.LocalProbeTemplateService] At LocalProbeTemplateService.java:[lines 108-112] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.agent.LocalProbeTemplateService] At LocalProbeTemplateService.java:[lines 115-118] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method intentionally throws RuntimeException. [io.cryostat.core.agent.ProbeTemplate] At ProbeTemplate.java:[lines 174-196] THROWS_METHOD_THROWS_RUNTIMEEXCEPTION
[ERROR] Medium: Method intentionally throws RuntimeException. [io.cryostat.core.agent.ProbeTemplate] At ProbeTemplate.java:[lines 95-147] THROWS_METHOD_THROWS_RUNTIMEEXCEPTION
[ERROR] Medium: Method intentionally throws RuntimeException. [io.cryostat.core.agent.ProbeTemplate] At ProbeTemplate.java:[lines 150-170] THROWS_METHOD_THROWS_RUNTIMEEXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.agent.ProbeTemplateService] In ProbeTemplateService.java THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.net.JFRConnection] At JFRConnection.java:[lines 96-97] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.net.JFRConnection] At JFRConnection.java:[lines 85-92] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.net.JFRConnection] At JFRConnection.java:[lines 206-215] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.net.JFRConnection] At JFRConnection.java:[lines 162-182] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.net.JFRConnection] At JFRConnection.java:[lines 104-114] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method intentionally throws RuntimeException. [io.cryostat.core.net.JFRConnection] At JFRConnection.java:[line 220] THROWS_METHOD_THROWS_RUNTIMEEXCEPTION
[ERROR] Medium: new io.cryostat.core.net.JFRConnectionToolkit(ClientWriter, FileSystem, Environment) may expose internal representation by storing an externally mutable object into JFRConnectionToolkit.fs [io.cryostat.core.net.JFRConnectionToolkit] At JFRConnectionToolkit.java:[line 66] EI_EXPOSE_REP2
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.net.JFRConnectionToolkit] At JFRConnectionToolkit.java:[line 71] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.net.JFRConnectionToolkit] At JFRConnectionToolkit.java:[line 75] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.net.JFRConnectionToolkit] At JFRConnectionToolkit.java:[lines 80-88] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: new io.cryostat.core.reports.InterruptibleReportGenerator(Logger, Set, ExecutorService) may expose internal representation by storing an externally mutable object into InterruptibleReportGenerator.transformers [io.cryostat.core.reports.InterruptibleReportGenerator] At InterruptibleReportGenerator.java:[line 105] EI_EXPOSE_REP2
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.reports.InterruptibleReportGenerator] At InterruptibleReportGenerator.java:[lines 340-352] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.reports.InterruptibleReportGenerator] At InterruptibleReportGenerator.java:[lines 174-191] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.reports.InterruptibleReportGenerator] At InterruptibleReportGenerator.java:[lines 123-154] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.templates.AbstractTemplateService] In AbstractTemplateService.java THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.templates.AbstractTemplateService] At AbstractTemplateService.java:[line 51] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: new io.cryostat.core.templates.LocalStorageTemplateService(FileSystem, Environment) may expose internal representation by storing an externally mutable object into LocalStorageTemplateService.fs [io.cryostat.core.templates.LocalStorageTemplateService] At LocalStorageTemplateService.java:[line 81] EI_EXPOSE_REP2
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.templates.LocalStorageTemplateService] At LocalStorageTemplateService.java:[line 72] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.templates.MergedTemplateService] At MergedTemplateService.java:[lines 88-94] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.templates.MergedTemplateService] At MergedTemplateService.java:[lines 67-70] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.templates.MergedTemplateService] At MergedTemplateService.java:[lines 75-81] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.templates.RemoteTemplateService] At RemoteTemplateService.java:[lines 106-110] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.templates.RemoteTemplateService] At RemoteTemplateService.java:[line 132] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.templates.RemoteTemplateService] At RemoteTemplateService.java:[line 62] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.templates.RemoteTemplateService] At RemoteTemplateService.java:[lines 77-80] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.templates.TemplateService] At TemplateService.java:[line 59] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.templates.TemplateService] In TemplateService.java THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.templates.TemplateService] In TemplateService.java THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.templates.TemplateService] At TemplateService.java:[line 53] THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
[ERROR] Medium: Method lists Exception in its throws clause. [io.cryostat.core.templates.TemplateService] In TemplateService.java THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

For example this method

public void defineEventProbes(String xmlDescription) throws Exception {

throws a general Exception exception. To 'solve' the bug, it could be replaced with

throws InstanceNotFoundException, MalformedObjectNameException, MBeanException, ReflectionException, IOException

And I'm not sure if that's what we want. I could also look into replacing the exception with a new class of exception, or just suppress them all together, @andrewazores WDYT?

from cryostat-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.