You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Julian Leichert (JIRA)" <ji...@apache.org> on 2017/09/14 08:54:00 UTC

[jira] [Updated] (OFBIZ-9715) [FB] Package org.apache.ofbiz.datafile

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

Julian Leichert updated OFBIZ-9715:
-----------------------------------
    Attachment: OFBIZ-9715_org.apache.ofbiz.datafile_bugfixes.patch

class DataFile
 - added Utf8 encoding
 - FileOutputStream surrounded with try-with-resources

class DataFile2EntityXml
 - added Utf8 encoding
 - surrounded Writers/Readers with try-with-resources
 - added null-check

class ModelDataFileReader
 - removed redundant nul-checks

class Record
 - added utf8
 - removed redundant null-check
 - Line 85: synchronized get

class RecordIterator
 - Line 233: changed to isEmpty, because != null is not the correct way to check a String

> [FB] Package org.apache.ofbiz.datafile
> --------------------------------------
>
>                 Key: OFBIZ-9715
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-9715
>             Project: OFBiz
>          Issue Type: Sub-task
>          Components: ALL APPLICATIONS, ALL COMPONENTS
>    Affects Versions: Trunk
>            Reporter: Julian Leichert
>            Priority: Minor
>         Attachments: OFBIZ-9715_org.apache.ofbiz.datafile_bugfixes.patch
>
>
> DataFile.java:76, RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE
> - RCN: Redundant nullcheck of reader, which is known to be non-null in org.apache.ofbiz.datafile.DataFile.makeDataFile(URL, String)
> This method contains a redundant check of a known non-null value against the constant null.
> DataFile.java:139, DM_DEFAULT_ENCODING
> - Dm: Found reliance on default encoding in org.apache.ofbiz.datafile.DataFile.readDataFile(String): String.getBytes()
> Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly.
> DataFile.java:190, RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE
> - RCN: Redundant nullcheck of fos, which is known to be non-null in org.apache.ofbiz.datafile.DataFile.writeDataFile(String)
> This method contains a redundant check of a known non-null value against the constant null.
> DataFile.java:206, DM_DEFAULT_ENCODING
> - Dm: Found reliance on default encoding in org.apache.ofbiz.datafile.DataFile.writeDataFile(): java.io.ByteArrayOutputStream.toString()
> Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly.
> DataFile.java:209, RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE
> - RCN: Redundant nullcheck of bos, which is known to be non-null in org.apache.ofbiz.datafile.DataFile.writeDataFile()
> This method contains a redundant check of a known non-null value against the constant null.
> DataFile.java:230, DM_DEFAULT_ENCODING
> - Dm: Found reliance on default encoding in org.apache.ofbiz.datafile.DataFile.writeRecords(OutputStream, List): String.getBytes()
> Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly.
> DataFile2EntityXml.java:52, OS_OPEN_STREAM_EXCEPTION_PATH
> - OS: org.apache.ofbiz.datafile.DataFile2EntityXml.writeToEntityXml(String, DataFile) may fail to close stream on exception
> The method creates an IO stream object, does not assign it to any fields, pass it to other methods, or return it, and does not appear to close it on all possible exception paths out of the method.  This may result in a file descriptor leak.  It is generally a good idea to use a finally block to ensure that streams are closed.
> DataFile2EntityXml.java:102, DM_DEFAULT_ENCODING
> - Dm: Found reliance on default encoding in org.apache.ofbiz.datafile.DataFile2EntityXml.main(String[]): new java.io.FileWriter(String)
> Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly.
> DataFile2EntityXml.java:102, OS_OPEN_STREAM_EXCEPTION_PATH
> - OS: org.apache.ofbiz.datafile.DataFile2EntityXml.main(String[]) may fail to close stream on exception
> The method creates an IO stream object, does not assign it to any fields, pass it to other methods, or return it, and does not appear to close it on all possible exception paths out of the method.  This may result in a file descriptor leak.  It is generally a good idea to use a finally block to ensure that streams are closed.
> DataFile2EntityXml.java:121, DE_MIGHT_IGNORE
> - DE: org.apache.ofbiz.datafile.DataFile2EntityXml.main(String[]) might ignore java.lang.Exception
> This method might ignore an exception.  In general, exceptions should be handled or reported in some way, or they should be thrown out of the method.
> DataFile2EntityXml.java:128, NP_NULL_ON_SOME_PATH
> - NP: Possible null pointer dereference of dataFile in org.apache.ofbiz.datafile.DataFile2EntityXml.main(String[])
> There is a branch of statement that, if executed, guarantees that a null value will be dereferenced, which would generate a NullPointerException when the code is executed. Of course, the problem might be that the branch or statement is infeasible and that the null pointer exception can't ever be executed; deciding that is beyond the ability of FindBugs.
> ModelDataFileReader.java:99, RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE
> - RCN: Redundant nullcheck of modelRecord, which is known to be non-null in org.apache.ofbiz.datafile.ModelDataFileReader.createModelDataFile(Element)
> This method contains a redundant check of a known non-null value against the constant null.
> ModelDataFileReader.java:152, RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE, Priorität: Normal
> - RCN: Redundant nullcheck of dataFile, which is known to be non-null in org.apache.ofbiz.datafile.ModelDataFileReader.createModelDataFiles()
> This method contains a redundant check of a known non-null value against the constant null.
> ModelField.java:27, SE_NO_SERIALVERSIONID
> - SnVI: org.apache.ofbiz.datafile.ModelField is Serializable; consider declaring a serialVersionUID
> This class implements the Serializable interface, but does not define a serialVersionUID field.  A change as simple as adding a reference to a .class object will add synthetic fields to the class, which will unfortunately change the implicit serialVersionUID (e.g., adding a reference to String.class will generate a static field class$java$lang$String). Also, different source code to bytecode compilers may use different naming conventions for synthetic variables generated for references to class objects or inner classes. To ensure interoperability of Serializable across versions, consider adding an explicit serialVersionUID.
> ModelRecord.java:65, URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD
> - UrF: Unread public/protected field: org.apache.ofbiz.datafile.ModelRecord.limit
> This field is never read.  The field is public or protected, so perhaps it is intended to be used with classes not seen as part of the analysis. If not, consider removing it from the class.
> Record.java:-1, SE_TRANSIENT_FIELD_NOT_RESTORED
> - Se: The field org.apache.ofbiz.datafile.Record.modelRecord is transient but isn't set by deserialization
> This class contains a field that is updated at multiple places in the class, thus it seems to be part of the state of the class. However, since the field is marked as transient and not set in readObject or readResolve, it will contain the default value in any deserialized instance of the class.
> Record.java:-1, UWF_NULL_FIELD, Priorität: Niedrig
> - UwF: Field only ever set to null: org.apache.ofbiz.datafile.Record.parentRecord
> All writes to this field are of the constant value null, and thus all reads of the field will return null. Check for errors, or remove it if it is useless.
> Record.java:52, SE_NO_SERIALVERSIONID
> - SnVI: org.apache.ofbiz.datafile.Record is Serializable; consider declaring a serialVersionUID
> This class implements the Serializable interface, but does not define a serialVersionUID field.  A change as simple as adding a reference to a .class object will add synthetic fields to the class, which will unfortunately change the implicit serialVersionUID (e.g., adding a reference to String.class will generate a static field class$java$lang$String). Also, different source code to bytecode compilers may use different naming conventions for synthetic variables generated for references to class objects or inner classes. To ensure interoperability of Serializable across versions, consider adding an explicit serialVersionUID.
> Record.java:85, UG_SYNC_SET_UNSYNC_GET
> - UG: org.apache.ofbiz.datafile.Record.get(String) is unsynchronized, org.apache.ofbiz.datafile.Record.set(String, Object, boolean) is synchronized
> This class contains similarly-named get and set methods where the set method is synchronized and the get method is not.  This may result in incorrect behavior at runtime, as callers of the get method will not necessarily see a consistent state for the object.  The get method should be made synchronized.
> Record.java:272, DM_DEFAULT_ENCODING
> - Dm: Found reliance on default encoding in org.apache.ofbiz.datafile.Record.setString(String, String): String.getBytes()
> Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly.
> Record.java:307, RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE
> - RCN: Redundant nullcheck of org.apache.ofbiz.datafile.Record.getModelRecord(), which is known to be non-null in org.apache.ofbiz.datafile.Record.getFixedString(String)
> This method contains a redundant check of a known non-null value against the constant null.
> RecordIterator.java:233, RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE
> - RCN: Redundant nullcheck of typeCode, which is known to be non-null in org.apache.ofbiz.datafile.RecordIterator.findModelForLine(String, int, ModelDataFile)
> This method contains a redundant check of a known non-null value against the constant null.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)