commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ferdinand Xu (JIRA)" <>
Subject [jira] [Commented] (CRYPTO-31) Make fields final wherever possible
Date Thu, 28 Apr 2016 07:33:13 GMT


Ferdinand Xu commented on CRYPTO-31:

PR was created at addressing this.

> Make fields final wherever possible
> -----------------------------------
>                 Key: CRYPTO-31
>                 URL:
>             Project: Commons Crypto
>          Issue Type: Improvement
>          Components: Stream
>            Reporter: Sebb
>            Assignee: Ferdinand Xu
>            Priority: Minor
> Final fields are automatically thread safe if the object itself is not modified.
> Whereas non-final fields are not necessarily thread-safe even if they are not mutated
- this is because of the Java memory model.
> There are several non-final fields that are not mutated once created. They should be
made final to improve thread-safety. This is particularly important for static fields since
they are more likely to be used by multiple threads.
> Note: such changes will not affect the public API if the fields are private or package-protected.
> The fields include:
> JavaSecureRandom.instance
> OpensslSecureRandom.fallback
> OpensslSecureRandom.nativeEnabled
> StreamInput.buf - since no point creating an instance if it is not going to be used for
reading, might as well create the buffer up front
> StreamOutput.bufferSize
> StreamOutput.buf - as for StreamInput
> StreamOutput.out - should also be private
> static NativeCodeLoader.nativeCodeLoaded
> static OSInfo.archMapping
> static ReflectionUtils.classLoader

This message was sent by Atlassian JIRA

View raw message