Skip to content

Commit

Permalink
7432: Update the spotbugs maven plugin
Browse files Browse the repository at this point in the history
Reviewed-by: hirt
  • Loading branch information
Patrick Reinhart committed Dec 23, 2021
1 parent 1c6ccc9 commit ae37757
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class TwitterOAuthHeaderGenerator {
private String tokenSecret;
private String version;

final static Random RANDOM = new Random();
final static Logger LOGGER = Logger.getLogger("TwitterOAuthHeaderGenerator");

public TwitterOAuthHeaderGenerator(String consumerKey, String consumerSecret, String token, String tokenSecret) {
Expand Down Expand Up @@ -183,11 +184,12 @@ private String getNonce() {
int leftLimit = 48; // numeral '0'
int rightLimit = 122; // letter 'z'
int targetStringLength = 10;
Random random = new Random();

return random.ints(leftLimit, rightLimit + 1).filter(i -> (i <= 57 || i >= 65) && (i <= 90 || i >= 97))
.limit(targetStringLength)
.collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append).toString();
synchronized (RANDOM) {
return RANDOM.ints(leftLimit, rightLimit + 1).filter(i -> (i <= 57 || i >= 65) && (i <= 90 || i >= 97))
.limit(targetStringLength)
.collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append).toString();
}
}

private String getTimestamp() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -412,6 +412,7 @@ public boolean createHtmlOverview(Browser browser, IPageContainer editor, IState
try {
this.showOk = Boolean.valueOf(state.getChild("report").getChild("showOk").getAttribute("value")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
} catch (NullPointerException npe) {
// ignore NPE when there is no state value is available
}
browser.addListener(SWT.MenuDetect, new Listener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021 Oracle and/or its affiliates. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -32,6 +32,8 @@
*/
package org.openjdk.jmc.rcp.application.scripting.model;

import java.util.Objects;

/**
* Represents a marker in the source code
*/
Expand All @@ -53,7 +55,7 @@ public int hashCode() {
public boolean equals(Object o) {
if (o instanceof Line) {
Line that = (Line) o;
return m_line == that.m_line;
return Objects.equals(m_line, that.m_line);
}
return false;
}
Expand Down
100 changes: 100 additions & 0 deletions configuration/spotbugs/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,106 @@
<Match>
<Bug pattern="DM_CONVERT_CASE"/>
</Match>

<!-- Allow low level access of overridable methods within the constructor -->
<Match>
<Or>
<Package name="~org\.openjdk\.jmc\.browser.*"/>
<Package name="~org\.openjdk\.jmc\.console.*"/>
<Package name="~org\.openjdk\.jmc\.flightrecorder.*"/>
<Package name="~org\.openjdk\.jmc\.flightress.*"/>
<Package name="~org\.openjdk\.jmc\.greychart.*"/>
<Package name="~org\.openjdk\.jmc\.ide.*"/>
<Package name="~org\.openjdk\.jmc\.joverflow.*"/>
<Package name="~org\.openjdk\.jmc\.rcp.*"/>
<Package name="~org\.openjdk\.jmc\.rjmx.*"/>
<Package name="~org\.openjdk\.jmc\.ui.*"/>
</Or>
<Bug pattern="MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR"/>
</Match>

<!-- Allowing Eclipse plug-in static fields using public static methods -->
<Match>
<Class name="~org\.openjdk\.jmc\..*Plugin" />
<Or>
<Method name="getDefault" />
</Or>
<Bug pattern="MS_EXPOSE_REP" />
</Match>
<Match>
<Or>
<!-- getDefault() -->
<Class name="org.openjdk.jmc.ui.common.labelingrules.NameConverter"/>
<!-- getSecurityManager() -->
<Class name="org.openjdk.jmc.ui.common.security.SecurityManagerFactory"/>
<!-- getInstance() -->
<Class name="org.openjdk.jmc.rjmx.preferences.JMXRMIPreferences"/>
<!-- getDefault() / getPluginLogger() -->
<Class name="org.openjdk.jmc.browser.attach.BrowserAttachPlugin"/>
<!-- getInstance() -->
<Class name="org.openjdk.jmc.browser.attach.LocalDescriptorProvider"/>
<!-- getLogger() -->
<Class name="org.openjdk.jmc.flightrecorder.configuration.ConfigurationToolkit"/>
<!-- getDefault() -->
<Class name="org.openjdk.jmc.flightrecorder.ui.FlightRecorderUI"/>
<!-- createSingleton() -->
<Class name="org.openjdk.jmc.console.agent.manager.model.PresetRepositoryFactory"/>
<!-- getDefault() / getLogger() -->
<Class name="org.openjdk.jmc.console.jconsole.Activator"/>
<!-- getDefault() -->
<Class name="org.openjdk.jmc.console.pde.Activator"/>
<!-- getDefault() -->
<Class name="org.openjdk.jmc.flightrecorder.controlpanel.ui.ControlPanel"/>
<!-- get*Delegate() -->
<Class name="org.openjdk.jmc.flightrecorder.controlpanel.ui.model.VolatileStorageDelegate"/>
<!-- getDefault() -->
<Class name="org.openjdk.jmc.flightrecorder.pde.Activator"/>
<!-- getUpdateSites() -->
<Class name="org.openjdk.jmc.rcp.application.p2.UpdateSiteURLToolkit"/>
<!-- getLogger() -->
<Class name="org.openjdk.jmc.rcp.logging.LoggingToolkit"/>
</Or>
<Bug pattern="MS_EXPOSE_REP" />
</Match>

<!-- Allowing catching a NullPointerException for a JBoss 4.2.3 specific workaround -->
<Match>
<Class name="org.openjdk.jmc.rjmx.internal.RJMXConnection"/>
<Method name="getMBeanInfos" />
<Bug pattern="DCN_NULLPOINTER_EXCEPTION" />
</Match>

<!-- Allowing catching a NullPointerException that could occur when VM dies -->
<Match>
<Class name="org.openjdk.jmc.attach.AttachToolkit"/>
<Method name="importFromPid" />
<Bug pattern="DCN_NULLPOINTER_EXCEPTION" />
</Match>

<!-- Allowing catching a NullPointerException that could occur when there is no state value -->
<Match>
<Class name="org.openjdk.jmc.flightrecorder.ui.overview.ResultReportUi"/>
<Method name="createHtmlOverview" />
<Bug pattern="DCN_NULLPOINTER_EXCEPTION" />
</Match>

<Match>
<Class name="org.openjdk.jmc.ui.common.security.SecurityManagerFactory"/>
<Bug pattern="EI_EXPOSE_STATIC_REP2" />
</Match>

<!-- Allowing non secure random to generate test data sets -->
<Match>
<Or>
<Class name="org.openjdk.jmc.joverflow.util.TestSetOfLongs"/>
<Class name="org.openjdk.jmc.joverflow.util.TestSetOfObjects"/>
</Or>
<Bug pattern="DMI_RANDOM_USED_ONLY_ONCE" />
</Match>
<Match>
<Class name="org.openjdk.jmc.browser.attach.LocalJVMToolkit$3"/>
<Bug pattern="DE_MIGHT_IGNORE" />
</Match>

<!-- Allowing Eclipse plug-in style singleton default instances -->
<Match>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<maven.resources.version>3.2.0</maven.resources.version>
<spotless.version>2.17.2</spotless.version>
<spotless.config.path>${basedir}/configuration/ide/eclipse/formatting/formatting.xml</spotless.config.path>
<spotbugs.version>4.2.2</spotbugs.version>
<spotbugs.version>4.5.2.0</spotbugs.version>
<buildId>${user.name}</buildId>
<!-- The version of the JDK embedded. When not embedding a JDK (this is
usually the case), leave this empty. If embedding a JDK, include a comma
Expand Down

0 comments on commit ae37757

Please sign in to comment.