nifi-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Bürli (Jira) <j...@apache.org>
Subject [jira] [Created] (NIFI-7419) ToStringBuilder.setDefaultStyle() is a singleton value and should not be called multiple times
Date Fri, 01 May 2020 08:35:00 GMT
Thomas Bürli created NIFI-7419:
----------------------------------

             Summary: ToStringBuilder.setDefaultStyle() is a singleton value and should not
be called multiple times
                 Key: NIFI-7419
                 URL: https://issues.apache.org/jira/browse/NIFI-7419
             Project: Apache NiFi
          Issue Type: Bug
          Components: Core Framework
    Affects Versions: 1.11.4
            Reporter: Thomas Bürli


According to the documentation of ToStringBuilder the method setDefaultStyle() should only
be called once since it sets a Singleton value.

{quote}This method sets a singleton default value, typically for the whole JVM. Changing this
default should generally only be done during application startup. It is recommended to pass
a ToStringStyle to the constructor instead of changing this global default.

This method is not intended for use from multiple threads. Internally, a volatile variable
is used to provide the guarantee that the latest value set is the value returned from getDefaultStyle().
[API Docs ToStringBuilder|https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/builder/ToStringBuilder.html#setDefaultStyle-org.apache.commons.lang3.builder.ToStringStyle-]
{quote}

I stumbled upon your code having it set in 4 classes
* nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/KeyDerivationFunction.java
* nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/repository/RepositoryType.java
* nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/EncryptionMethod.java
* nifi-commons/nifi-security-utils/src/main/java/org/apache/nifi/security/util/crypto/HashAlgorithm.java

[Github Search Result|https://github.com/apache/nifi/search?q=setDefaultStyle&unscoped_q=setDefaultStyle]

This could have a side effects or performance impacts but since it's only in the toString
method I don't think it has an impact.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message