[jboss-cvs] JBossAS SVN: r104543 - in projects/jboss-jca/trunk: validator/src/main/java/org/jboss/jca/validator and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu May 6 20:23:38 EDT 2010
Author: jeff.zhang
Date: 2010-05-06 20:23:37 -0400 (Thu, 06 May 2010)
New Revision: 104543
Modified:
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AbstractCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/JCA16AnnoProfile.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Main.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Utils.java
projects/jboss-jca/trunk/validator/src/main/java/org/jboss/jca/validator/Main.java
projects/jboss-jca/trunk/validator/src/main/java/org/jboss/jca/validator/ant/ValidatorTask.java
projects/jboss-jca/trunk/validator/src/main/java/org/jboss/jca/validator/rules/mc/MCGetMetaData.java
Log:
fix some findbugs warning
Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AbstractCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AbstractCodeGen.java 2010-05-07 00:00:34 UTC (rev 104542)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AbstractCodeGen.java 2010-05-07 00:23:37 UTC (rev 104543)
@@ -24,6 +24,7 @@
import java.io.IOException;
import java.io.Writer;
import java.net.URL;
+import java.util.Locale;
/**
* Abstract CodeGenerator.
@@ -162,7 +163,7 @@
String upcaseFisrt(String name)
{
StringBuilder sb = new StringBuilder();
- sb.append(name.substring(0, 1).toUpperCase());
+ sb.append(name.substring(0, 1).toUpperCase(Locale.ENGLISH));
sb.append(name.substring(1));
return sb.toString();
}
Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/JCA16AnnoProfile.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/JCA16AnnoProfile.java 2010-05-07 00:00:34 UTC (rev 104542)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/JCA16AnnoProfile.java 2010-05-07 00:23:37 UTC (rev 104543)
@@ -22,6 +22,7 @@
package org.jboss.jca.codegenerator;
import java.io.FileWriter;
+import java.io.IOException;
/**
* A JCA16AnnoProfile.
@@ -62,7 +63,7 @@
*/
private void generateClassCode(Definition def, String className)
{
- if (className.equals("") || className == null)
+ if (className == null || className.equals(""))
return;
try
@@ -81,6 +82,10 @@
fw.flush();
fw.close();
}
+ catch (IOException ioe)
+ {
+ ioe.printStackTrace();
+ }
catch (Exception e)
{
e.printStackTrace();
Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Main.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Main.java 2010-05-07 00:00:34 UTC (rev 104542)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Main.java 2010-05-07 00:23:37 UTC (rev 104543)
@@ -133,7 +133,7 @@
System.out.println(dbconf.getString("code.wrote"));
}
- catch (Exception e)
+ catch (IOException e)
{
e.printStackTrace();
}
Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Utils.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Utils.java 2010-05-07 00:00:34 UTC (rev 104542)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Utils.java 2010-05-07 00:23:37 UTC (rev 104543)
@@ -106,12 +106,18 @@
File path = new File(outDir, directory);
if (!path.exists())
- path.mkdirs();
+ {
+ if (!path.mkdirs())
+ throw new IOException("outdir can't be created");
+ }
File file = new File(path.getAbsolutePath() + File.separatorChar + name);
if (file.exists())
- file.delete();
+ {
+ if (!file.delete())
+ throw new IOException("there is exist file, please check");
+ }
return new FileWriter(file);
}
@@ -127,12 +133,18 @@
{
File path = new File(outDir);
if (!path.exists())
- path.mkdirs();
+ {
+ if (!path.mkdirs())
+ throw new IOException("outdir can't be created");
+ }
File file = new File(path.getAbsolutePath() + File.separatorChar + name);
if (file.exists())
- file.delete();
+ {
+ if (!file.delete())
+ throw new IOException("there is exist file, please check");
+ }
return new FileWriter(file);
}
Modified: projects/jboss-jca/trunk/validator/src/main/java/org/jboss/jca/validator/Main.java
===================================================================
--- projects/jboss-jca/trunk/validator/src/main/java/org/jboss/jca/validator/Main.java 2010-05-07 00:00:34 UTC (rev 104542)
+++ projects/jboss-jca/trunk/validator/src/main/java/org/jboss/jca/validator/Main.java 2010-05-07 00:23:37 UTC (rev 104543)
@@ -171,10 +171,11 @@
File report = new File(reportDirectory, reportName);
FileWriter fw = null;
+ BufferedWriter bw = null;
try
{
fw = new FileWriter(report);
- BufferedWriter bw = new BufferedWriter(fw, 8192);
+ bw = new BufferedWriter(fw, 8192);
bw.write(fh.asText(validator.getResourceBundle()));
bw.flush();
}
@@ -184,17 +185,17 @@
}
finally
{
- if (fw != null)
+ try
{
- try
- {
+ if (bw != null)
+ bw.close();
+ if (fw != null)
fw.close();
- }
- catch (IOException ignore)
- {
- // Ignore
- }
}
+ catch (IOException ignore)
+ {
+ // Ignore
+ }
}
exitCode = FAIL;
Modified: projects/jboss-jca/trunk/validator/src/main/java/org/jboss/jca/validator/ant/ValidatorTask.java
===================================================================
--- projects/jboss-jca/trunk/validator/src/main/java/org/jboss/jca/validator/ant/ValidatorTask.java 2010-05-07 00:00:34 UTC (rev 104542)
+++ projects/jboss-jca/trunk/validator/src/main/java/org/jboss/jca/validator/ant/ValidatorTask.java 2010-05-07 00:23:37 UTC (rev 104543)
@@ -137,10 +137,8 @@
try
{
Thread.currentThread().setContextClassLoader(ValidatorTask.class.getClassLoader());
-
- Main main = new Main();
- main.validate(new File(getRarFile()).toURI().toURL(), getOutputDir(), getCommandLine().getClasspath().list());
+ Main.validate(new File(getRarFile()).toURI().toURL(), getOutputDir(), getCommandLine().getClasspath().list());
}
catch (Throwable t)
{
Modified: projects/jboss-jca/trunk/validator/src/main/java/org/jboss/jca/validator/rules/mc/MCGetMetaData.java
===================================================================
--- projects/jboss-jca/trunk/validator/src/main/java/org/jboss/jca/validator/rules/mc/MCGetMetaData.java 2010-05-07 00:00:34 UTC (rev 104542)
+++ projects/jboss-jca/trunk/validator/src/main/java/org/jboss/jca/validator/rules/mc/MCGetMetaData.java 2010-05-07 00:23:37 UTC (rev 104543)
@@ -65,22 +65,29 @@
ManagedConnection.class.isAssignableFrom(v.getClazz()))
{
boolean error = false;
- ValidateObject vo = (ValidateObject)v;
-
- try
+ ValidateObject vo = null;
+ if (v instanceof ValidateObject)
+ vo = (ValidateObject)v;
+ if (vo == null)
{
- Class clz = vo.getClazz();
- Method gmd = clz.getMethod("getMetaData", (Class[])null);
- Object md = gmd.invoke(vo.getObject(), (Object[])null);
-
- if (md == null)
- error = true;
+ error = true;
}
- catch (Throwable t)
+ else
{
- // Ignore
+ try
+ {
+ Class clz = vo.getClazz();
+ Method gmd = clz.getMethod("getMetaData", (Class[])null);
+ Object md = gmd.invoke(vo.getObject(), (Object[])null);
+
+ if (md == null)
+ error = true;
+ }
+ catch (Throwable t)
+ {
+ // Ignore
+ }
}
-
if (error)
{
List<Failure> failures = new ArrayList<Failure>(1);
More information about the jboss-cvs-commits
mailing list