Use Writer, always close FileWriter exactly once
This commit is contained in:
parent
6793780d4f
commit
27f212f3ec
@ -345,12 +345,11 @@ public class LocalRepoManager {
|
|||||||
serializer = XmlPullParserFactory.newInstance().newSerializer();
|
serializer = XmlPullParserFactory.newInstance().newSerializer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build(FileWriter output) throws IOException, LocalRepoKeyStore.InitException {
|
public void build(Writer output) throws IOException, LocalRepoKeyStore.InitException {
|
||||||
serializer.setOutput(output);
|
serializer.setOutput(output);
|
||||||
serializer.startDocument(null, null);
|
serializer.startDocument(null, null);
|
||||||
tagFdroid();
|
tagFdroid();
|
||||||
serializer.endDocument();
|
serializer.endDocument();
|
||||||
output.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tagFdroid() throws IOException, LocalRepoKeyStore.InitException {
|
private void tagFdroid() throws IOException, LocalRepoKeyStore.InitException {
|
||||||
@ -486,8 +485,7 @@ public class LocalRepoManager {
|
|||||||
|
|
||||||
public void writeIndexJar() throws IOException {
|
public void writeIndexJar() throws IOException {
|
||||||
|
|
||||||
FileWriter writer;
|
FileWriter writer = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
writer = new FileWriter(xmlIndex);
|
writer = new FileWriter(xmlIndex);
|
||||||
new IndexXmlBuilder(context, apps).build(writer);
|
new IndexXmlBuilder(context, apps).build(writer);
|
||||||
@ -495,6 +493,8 @@ public class LocalRepoManager {
|
|||||||
Log.e(TAG, "Could not write index jar", e);
|
Log.e(TAG, "Could not write index jar", e);
|
||||||
Toast.makeText(context, R.string.failed_to_create_index, Toast.LENGTH_LONG).show();
|
Toast.makeText(context, R.string.failed_to_create_index, Toast.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
|
} finally {
|
||||||
|
Utils.closeQuietly(writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferedOutputStream bo = new BufferedOutputStream(new FileOutputStream(xmlIndexJarUnsigned));
|
BufferedOutputStream bo = new BufferedOutputStream(new FileOutputStream(xmlIndexJarUnsigned));
|
||||||
@ -515,7 +515,6 @@ public class LocalRepoManager {
|
|||||||
bi.close();
|
bi.close();
|
||||||
jo.close();
|
jo.close();
|
||||||
bo.close();
|
bo.close();
|
||||||
writer.close();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LocalRepoKeyStore.get(context).signZip(xmlIndexJarUnsigned, xmlIndexJar);
|
LocalRepoKeyStore.get(context).signZip(xmlIndexJarUnsigned, xmlIndexJar);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user