felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Ziegeler (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FELIX-4266) findbugs reported errors related to arrays being stored/returned directly
Date Tue, 15 Sep 2015 13:47:45 GMT

    [ https://issues.apache.org/jira/browse/FELIX-4266?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14745477#comment-14745477
] 

Carsten Ziegeler commented on FELIX-4266:
-----------------------------------------

The class is not part of the code base anymore

> findbugs reported errors related to arrays being stored/returned directly 
> --------------------------------------------------------------------------
>
>                 Key: FELIX-4266
>                 URL: https://issues.apache.org/jira/browse/FELIX-4266
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: framework-4.2.1
>            Reporter: Sahoo
>            Assignee: Sahoo
>            Priority: Minor
>
> FindBugs on Felix reported following two issues:
> - Should change code to make a clone of the return value and return the copy, not the
internal representation.
> - Should change code to store a clone of the external mutable object.
> Below are the fixes to these two issues:  
> framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Library.java
 (revision 1528211)
> +++ framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Library.java
 (working copy)
> @@ -18,10 +18,11 @@
>   */
>  package org.apache.felix.framework.util.manifestparser;
> +import org.osgi.framework.Constants;
> +
>  import java.util.ArrayList;
>  import java.util.List;
>  import java.util.Map;
> -import org.osgi.framework.Constants;
>  public class R4Library
>  {
> @@ -37,10 +38,10 @@
>          String[] languages, String selectionFilter) throws Exception
>      {
>          m_libraryFile = libraryFile;
> -        m_osnames = osnames;
> -        m_processors = processors;
> -        m_osversions = osversions;
> -        m_languages = languages;
> +        m_osnames = osnames == null ? osnames : osnames.clone();
> +        m_processors = processors == null ? processors : processors.clone();
> +        m_osversions = osversions == null ? osversions : osversions.clone();
> +        m_languages = languages == null ? languages : languages.clone();
>          m_selectionFilter = selectionFilter;
>      }
> @@ -51,22 +52,22 @@
>      public String[] getOSNames()
>      {
> -        return m_osnames;
> +        return m_osnames == null ? m_osnames : m_osnames.clone();
>      }
>      public String[] getProcessors()
>      {
> -        return m_processors;
> +        return m_processors == null ? m_processors : m_processors.clone();
>      }
>      public String[] getOSVersions()
>      {
> -        return m_osversions;
> +        return m_osversions == null ? m_osversions : m_osversions.clone();
>      }
>      public String[] getLanguages()
>      {
> -        return m_languages;
> +        return m_languages == null ? m_languages : m_languages.clone();
>      }
>      public String getSelectionFilter()
> @@ -184,4 +185,4 @@
>          }
>          return "*";
>      }
> -}
> \ No newline at end of file
> +} 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message