Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2)

125907 mward: ACE-5052: close PrintWriter


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.1.N/root@125933 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alexandra Leahu
2016-04-28 09:15:22 +00:00
parent e503014fe7
commit e52c6301a4

View File

@@ -1976,44 +1976,51 @@ public class SchemaBootstrap extends AbstractLifecycleBean
dialect.getClass().getSimpleName(), dialect.getClass().getSimpleName(),
reference.getDbPrefix() reference.getDbPrefix()
}; };
PrintWriter pw; PrintWriter pw = null;
File outputFile = null; File outputFile = null;
if (out == null)
try
{ {
String outputFileName = MessageFormat.format(outputFileNameTemplate, outputFileNameParams); if (out == null)
{
String outputFileName = MessageFormat.format(outputFileNameTemplate, outputFileNameParams);
outputFile = TempFileProvider.createTempFile(outputFileName, ".txt"); outputFile = TempFileProvider.createTempFile(outputFileName, ".txt");
try try
{ {
pw = new PrintWriter(outputFile, SchemaComparator.CHAR_SET); pw = new PrintWriter(outputFile, SchemaComparator.CHAR_SET);
}
catch (FileNotFoundException error)
{
throw new RuntimeException("Unable to open file for writing: " + outputFile);
}
catch (UnsupportedEncodingException error)
{
throw new RuntimeException("Unsupported char set: " + SchemaComparator.CHAR_SET, error);
}
} }
catch (FileNotFoundException error) else
{ {
throw new RuntimeException("Unable to open file for writing: " + outputFile); pw = out;
} }
catch (UnsupportedEncodingException error)
// Populate the file with details of the comparison's results.
for (Result result : results)
{ {
throw new RuntimeException("Unsupported char set: " + SchemaComparator.CHAR_SET, error); pw.print(result.describe());
pw.print(SchemaComparator.LINE_SEPARATOR);
} }
} }
else finally
{ {
pw = out; // We care only about output streams for reporting, which are created specially for current reference resource...
} if (null == out)
{
// Populate the file with details of the comparison's results. pw.close();
for (Result result : results) }
{
pw.print(result.describe());
pw.print(SchemaComparator.LINE_SEPARATOR);
} }
// We care only about output streams for reporting, which are created specially for current reference resource...
if (null == out)
{
pw.close();
}
if (results.size() == 0) if (results.size() == 0)
{ {