Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7718119C2E for ; Thu, 28 Apr 2016 03:34:13 +0000 (UTC) Received: (qmail 70350 invoked by uid 500); 28 Apr 2016 03:34:13 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 69840 invoked by uid 500); 28 Apr 2016 03:34:13 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 69809 invoked by uid 99); 28 Apr 2016 03:34:13 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Apr 2016 03:34:13 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id DEF6B2C1F5D for ; Thu, 28 Apr 2016 03:34:12 +0000 (UTC) Date: Thu, 28 Apr 2016 03:34:12 +0000 (UTC) From: "Dapeng Sun (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (CRYPTO-30) Mutable fields should be private MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CRYPTO-30?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Dapeng Sun updated CRYPTO-30: ----------------------------- Affects Version/s: 1.0.0 > Mutable fields should be private > -------------------------------- > > Key: CRYPTO-30 > URL: https://issues.apache.org/jira/browse/CRYPTO-30 > Project: Commons Crypto > Issue Type: Bug > Components: Stream > Affects Versions: 1.0.0 > Reporter: Sebb > Assignee: Ferdinand Xu > Fix For: 1.0.0 > > > Mutable fields should be private or possibly package-protected, never protected or public. > Once a field is published, it's impossible to ensure that it is properly synchronised, and it is impossible to change the implementation without API breakage. > Only constants should be published. > If there is really a need to access the field externally, this should be done through getters/setters, as those allow synchronisation to be added and make it easier to change the implementation. > Also, it's easy to add a getter/setter later if access is found to be needed. > Don't add one 'just in case' because it cannot easily be removed. > This observation applies to: > StreamOutput.out > CTRCipherInputStream.streamOffset > CTRCipherOutputStream.streamOffset > CipherInputStream - lots of protected mutable state > CipherOutputStream - ditto -- This message was sent by Atlassian JIRA (v6.3.4#6332)