Skip to content

Commit

Permalink
Fix several dozens of errors/warnings reported by FindBugs
Browse files Browse the repository at this point in the history
(cherry picked from commit 861b722)
  • Loading branch information
Petr Siroky authored and nmirasch committed Mar 18, 2014
1 parent b190e1e commit 9b54a03
Show file tree
Hide file tree
Showing 48 changed files with 536 additions and 567 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ public void createProject( final String jobId,
pom.getGav().setVersion( "1.0" );

try {
Project project = projectService.newProject( makeRepository( Paths.convert( repositoryPath ) ),
projectName,
pom,
"/" );
projectService.newProject( makeRepository( Paths.convert( repositoryPath ) ),
projectName,
pom,
"/" );
} catch ( org.uberfire.java.nio.file.FileAlreadyExistsException e ) {
result.setStatus( JobStatus.DUPLICATE_RESOURCE );
result.setResult( "Project [" + projectName + "] already exists" );
Expand Down Expand Up @@ -350,27 +350,20 @@ public void fire( TestResultMessage event ) {
jobResultEvent.fire( result );
}

//@Override
@Override
public Event<TestResultMessage> select( Annotation... qualifiers ) {
// TODO Auto-generated method stub
return null;
}

//@Override
@Override
public <U extends TestResultMessage> Event<U> select(
Class<U> subtype,
Annotation... qualifiers ) {
// TODO Auto-generated method stub
return null;
}

//@Override
public <U extends TestResultMessage> Event<U> select(
TypeLiteral<U> subtype,
Annotation... qualifiers ) {
// TODO Auto-generated method stub
return null;
}
} );
}
}
Expand Down Expand Up @@ -426,7 +419,7 @@ public void createOrganizationalUnit( final String jobId,
JobResult result = new JobResult();
result.setJobId( jobId );

if ( organizationalUnitName == null || organizationalUnitName == null ) {
if ( organizationalUnitName == null || organizationalUnitOwner == null ) {
result.setStatus( JobStatus.BAD_REQUEST );
result.setResult( "OrganizationalUnit name and owner must be provided" );
jobResultEvent.fire( result );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.drools.workbench.screens.drltext.backend.server;

import java.io.ByteArrayInputStream;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
Expand All @@ -25,6 +26,7 @@
import javax.inject.Inject;
import javax.inject.Named;

import com.google.common.base.Charsets;
import org.drools.workbench.models.commons.backend.packages.PackageNameParser;
import org.drools.workbench.models.commons.backend.packages.PackageNameWriter;
import org.drools.workbench.models.datamodel.oracle.ProjectDataModelOracle;
Expand Down Expand Up @@ -237,7 +239,7 @@ public List<ValidationMessage> validate( final Path path,
final String content ) {
try {
return genericValidator.validate( path,
new ByteArrayInputStream( content.getBytes() ),
new ByteArrayInputStream( content.getBytes( Charsets.UTF_8 ) ),
FILTER_JAVA,
FILTER_DRLS );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void addCellValue( final int row,
final String value ) {
final DTCellValue52 dcv = new DTCellValue52();
try {
dcv.setNumericValue( new Long( value ) );
dcv.setNumericValue( Long.valueOf( value ) );
} catch ( NumberFormatException nfe ) {
final String message = "Duration is not an long literal, in cell " + RuleSheetParserUtil.rc2name( row,
column );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void populateDecisionTable( final GuidedDecisionTable52 dtable ) {
final int maxRow = this.values.size();
for ( int iRow = 0; iRow < maxRow; iRow++ ) {
final DTCellValue52 dcv = this.values.get( iRow );
dcv.setNumericValue( new Integer( maxRow - iRow ) );
dcv.setNumericValue( Integer.valueOf( maxRow - iRow ) );
}
}
dtable.getAttributeCols().add( column );
Expand All @@ -70,7 +70,7 @@ public void addCellValue( final int row,
}
final DTCellValue52 dcv = new DTCellValue52();
try {
dcv.setNumericValue( new Integer( value ) );
dcv.setNumericValue( Integer.valueOf( value ) );
} catch ( NumberFormatException nfe ) {
final String message = "Priority is not an integer literal, in cell " + RuleSheetParserUtil.rc2name( row,
column );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void populateDecisionTable( final GuidedDecisionTable52 dtable ) {
for ( int iRow = 0; iRow < this.values.size(); iRow++ ) {
dtable.getData().add( new ArrayList<DTCellValue52>() );
final DTCellValue52 dcv = this.values.get( iRow );
dcv.setNumericValue( new Integer( iRow + 1 ) );
dcv.setNumericValue( Integer.valueOf( iRow + 1 ) );
dtable.getData().get( iRow ).add( 0,
dcv );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.drools.workbench.screens.factmodel.model.FactMetaModel;
import org.drools.workbench.screens.factmodel.model.FactModels;
import org.drools.workbench.screens.factmodel.model.FieldMetaModel;
import org.uberfire.commons.validation.Preconditions;

import static java.util.Collections.*;

Expand Down Expand Up @@ -113,7 +114,9 @@ public static FactModels unmarshal( final String content ) {

private static List<FactMetaModel> toModel( String drl )
throws DroolsParserException {
if ( drl != null && ( drl.startsWith( "#advanced" ) || drl.startsWith( "//advanced" ) ) ) {
Preconditions.checkNotNull(drl, "The string representing DRL can't be null!");

if ( drl.startsWith( "#advanced" ) || drl.startsWith( "//advanced" ) ) {
throw new DroolsParserException( "Using advanced editor" );
}
final DrlParser parser = new DrlParser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import javax.inject.Inject;
import javax.inject.Named;

import com.google.common.base.Charsets;
import org.drools.workbench.models.datamodel.oracle.ProjectDataModelOracle;
import org.drools.workbench.screens.globals.backend.server.util.GlobalsPersistence;
import org.drools.workbench.screens.globals.model.GlobalsEditorContent;
Expand Down Expand Up @@ -244,7 +245,9 @@ public List<ValidationMessage> validate( final Path path,
final GlobalsModel content ) {
try {
return genericValidator.validate( path,
new ByteArrayInputStream( GlobalsPersistence.getInstance().marshal( content ).getBytes() ),
new ByteArrayInputStream(
GlobalsPersistence.getInstance().marshal( content ).getBytes( Charsets.UTF_8 )
),
FILTER_JAVA );

} catch ( Exception e ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import javax.inject.Inject;
import javax.inject.Named;

import com.google.common.base.Charsets;
import org.drools.workbench.models.datamodel.oracle.PackageDataModelOracle;
import org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition;
import org.drools.workbench.models.guided.dtable.backend.GuidedDTXMLPersistence;
Expand Down Expand Up @@ -272,7 +273,9 @@ public List<ValidationMessage> validate( final Path path,
final GuidedDecisionTable52 content ) {
try {
return genericValidator.validate( path,
new ByteArrayInputStream( GuidedDTXMLPersistence.getInstance().marshal( content ).getBytes() ),
new ByteArrayInputStream(
GuidedDTXMLPersistence.getInstance().marshal( content ).getBytes( Charsets.UTF_8 )
),
FILTER_JAVA,
FILTER_GLOBALS,
FILTER_DSLS );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ private void convertDTCellValueFromString( DataType.DataTypes dataType,
String text = dcv.getStringValue();
switch ( dataType ) {
case BOOLEAN:
dcv.setBooleanValue( ( text == null ? false : Boolean.valueOf( text ) ) );
dcv.setBooleanValue( ( text == null ? Boolean.FALSE : Boolean.valueOf( text ) ) );
break;
case DATE:
Date d = null;
Expand Down Expand Up @@ -357,7 +357,7 @@ private void convertDTCellValueFromString( DataType.DataTypes dataType,
Byte byteValue = null;
try {
if ( text != null ) {
byteValue = new Byte( text );
byteValue = Byte.valueOf( text );
}
} catch ( Exception e ) {
}
Expand All @@ -367,7 +367,7 @@ private void convertDTCellValueFromString( DataType.DataTypes dataType,
Double doubleValue = null;
try {
if ( text != null ) {
doubleValue = new Double( text );
doubleValue = Double.valueOf( text );
}
} catch ( Exception e ) {
}
Expand All @@ -377,7 +377,7 @@ private void convertDTCellValueFromString( DataType.DataTypes dataType,
Float floatValue = null;
try {
if ( text != null ) {
floatValue = new Float( text );
floatValue = Float.valueOf( text );
}
} catch ( Exception e ) {
}
Expand All @@ -387,7 +387,7 @@ private void convertDTCellValueFromString( DataType.DataTypes dataType,
Integer integerValue = null;
try {
if ( text != null ) {
integerValue = new Integer( text );
integerValue = Integer.valueOf( text );
}
} catch ( Exception e ) {
}
Expand All @@ -397,7 +397,7 @@ private void convertDTCellValueFromString( DataType.DataTypes dataType,
Long longValue = null;
try {
if ( text != null ) {
longValue = new Long( text );
longValue = Long.valueOf( text );
}
} catch ( Exception e ) {
}
Expand All @@ -407,7 +407,7 @@ private void convertDTCellValueFromString( DataType.DataTypes dataType,
Short shortValue = null;
try {
if ( text != null ) {
shortValue = new Short( text );
shortValue = Short.valueOf( text );
}
} catch ( Exception e ) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ public String getBoundFactType( String boundName ) {
}
}
}
return new String();
return "";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public class ActionWorkItemPopup extends FormStylePopup {

private ActionWorkItemCol52 editingCol;
private GuidedDecisionTable52 model;
private Path path;
private WorkItemParametersWidget workItemInputParameters;
private Map<String, PortableWorkDefinition> workItemDefinitionsMap;
private int workItemInputParametersIndex;
Expand All @@ -70,7 +69,6 @@ public ActionWorkItemPopup( final Path path,
final boolean isNew,
final boolean isReadOnly ) {
this.editingCol = cloneActionWorkItemColumn( col );
this.path = path;
this.model = model;
this.isReadOnly = isReadOnly;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -687,13 +687,13 @@ private AbstractRestrictedEntryTextBox makeNumericByteTextBox( final DTCellValue

public void onValueChange( ValueChangeEvent<String> event ) {
try {
value.setNumericValue( new Byte( event.getValue() ) );
value.setNumericValue( Byte.valueOf( event.getValue() ) );
} catch ( NumberFormatException nfe ) {
if ( allowEmptyValues ) {
value.setNumericValue( (Byte) null );
tb.setValue( "" );
} else {
value.setNumericValue( new Byte( "0" ) );
value.setNumericValue( Byte.valueOf( "0" ) );
tb.setValue( "0" );
}
}
Expand Down Expand Up @@ -774,13 +774,13 @@ private AbstractRestrictedEntryTextBox makeNumericIntegerTextBox( final DTCellVa

public void onValueChange( ValueChangeEvent<String> event ) {
try {
value.setNumericValue( new Integer( event.getValue() ) );
value.setNumericValue( Integer.valueOf( event.getValue() ) );
} catch ( NumberFormatException nfe ) {
if ( allowEmptyValues ) {
value.setNumericValue( (Integer) null );
tb.setValue( "" );
} else {
value.setNumericValue( new Integer( "0" ) );
value.setNumericValue( 0 );
tb.setValue( "0" );
}
}
Expand All @@ -803,13 +803,13 @@ private AbstractRestrictedEntryTextBox makeNumericLongTextBox( final DTCellValue

public void onValueChange( ValueChangeEvent<String> event ) {
try {
value.setNumericValue( new Long( event.getValue() ) );
value.setNumericValue( Long.valueOf( event.getValue() ) );
} catch ( NumberFormatException nfe ) {
if ( allowEmptyValues ) {
value.setNumericValue( (Long) null );
tb.setValue( "" );
} else {
value.setNumericValue( new Long( "0" ) );
value.setNumericValue( 0L );
tb.setValue( "0" );
}
}
Expand All @@ -832,13 +832,13 @@ private AbstractRestrictedEntryTextBox makeNumericShortTextBox( final DTCellValu

public void onValueChange( ValueChangeEvent<String> event ) {
try {
value.setNumericValue( new Short( event.getValue() ) );
value.setNumericValue( Short.valueOf( event.getValue() ) );
} catch ( NumberFormatException nfe ) {
if ( allowEmptyValues ) {
value.setNumericValue( (Short) null );
tb.setValue( "" );
} else {
value.setNumericValue( new Short( "0" ) );
value.setNumericValue( Short.valueOf( "0" ) );
tb.setValue( "0" );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public static Widget getDefaultValueWidget( final AttributeCol52 ac,
final boolean isReadOnly,
final DefaultValueChangedEventHandler defaultValueChangedEventHandler ) {
Widget editor = null;
final AttributeCol52 originCol = ac;
final String attributeName = ac.getAttribute();
if ( attributeName.equals( RuleAttributeWidget.RULEFLOW_GROUP_ATTR )
|| attributeName.equals( RuleAttributeWidget.AGENDA_GROUP_ATTR )
Expand Down Expand Up @@ -129,9 +128,9 @@ public void onValueChange( ValueChangeEvent<String> event ) {
public void onValueChange( ValueChangeEvent<String> event ) {
DTCellValue52 clonedDefaultValue = defaultValue.cloneDefaultValueCell();
try {
defaultValue.setNumericValue( new Integer( event.getValue() ) );
defaultValue.setNumericValue( Integer.valueOf( event.getValue() ) );
} catch ( NumberFormatException nfe ) {
defaultValue.setNumericValue( new Integer( "0" ) );
defaultValue.setNumericValue( 0 );
tb.setValue( "0" );
} finally {
defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue, clonedDefaultValue));
Expand Down Expand Up @@ -159,9 +158,9 @@ public void onValueChange( ValueChangeEvent<String> event ) {
public void onValueChange( ValueChangeEvent<String> event ) {
DTCellValue52 clonedDefaultValue = defaultValue.cloneDefaultValueCell();
try {
defaultValue.setNumericValue( new Long( event.getValue() ) );
defaultValue.setNumericValue( Long.valueOf( event.getValue() ) );
} catch ( NumberFormatException nfe ) {
defaultValue.setNumericValue( new Long( "0" ) );
defaultValue.setNumericValue( 0L );
tb.setValue( "0" );
} finally {
defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue, clonedDefaultValue));
Expand Down Expand Up @@ -274,9 +273,9 @@ public void onChange( ChangeEvent event ) {
private static void assertIntegerDefaultValue( final DTCellValue52 dcv ) {
if ( dcv.getNumericValue() == null ) {
try {
dcv.setNumericValue( new Integer( dcv.getStringValue() ) );
dcv.setNumericValue( Integer.valueOf ( dcv.getStringValue() ) );
} catch ( NumberFormatException nfe ) {
dcv.setNumericValue( new Integer( "0" ) );
dcv.setNumericValue( 0 );
}
}
}
Expand All @@ -285,17 +284,17 @@ private static void assertIntegerDefaultValue( final DTCellValue52 dcv ) {
private static void assertLongDefaultValue( final DTCellValue52 dcv ) {
if ( dcv.getNumericValue() == null ) {
try {
dcv.setNumericValue( new Long( dcv.getStringValue() ) );
dcv.setNumericValue( Long.valueOf( dcv.getStringValue() ) );
} catch ( NumberFormatException nfe ) {
dcv.setNumericValue( new Long( "0" ) );
dcv.setNumericValue( 0L );
}
}
}

//Legacy DefaultValues always used String to store the value; so attempt to convert it
private static void assertBooleanDefaultValue( final DTCellValue52 dcv ) {
if ( dcv.getBooleanValue() == null ) {
dcv.setBooleanValue( new Boolean( dcv.getStringValue() ) );
dcv.setBooleanValue( Boolean.valueOf( dcv.getStringValue() ) );
}
}

Expand Down

0 comments on commit 9b54a03

Please sign in to comment.