You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "Thomas Bürli (Jira)" <ji...@apache.org> on 2020/05/01 08:50:00 UTC

[jira] [Updated] (NIFI-7419) ToStringBuilder.setDefaultStyle() is a singleton value and should not be called multiple times

     [ https://issues.apache.org/jira/browse/NIFI-7419?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thomas Bürli updated NIFI-7419:
-------------------------------
    Status: Patch Available  (was: Open)

Created a pull request for it
https://github.com/apache/nifi/pull/4247

> 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
>            Priority: Minor
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> 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)