Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMykola Nikishov2016-12-17 19:13:21 +0000
committerPascal Rapicault2017-03-29 14:08:51 +0000
commit7c9545086de9dda759cf3bc776ef4046513540b8 (patch)
treea35281874d64f9c39539508553b4676dc7e1d373
parent6493f6f243b9f6ce0017dd3ba5a822f63918a648 (diff)
downloadrt.equinox.p2-7c9545086de9dda759cf3bc776ef4046513540b8.tar.gz
rt.equinox.p2-7c9545086de9dda759cf3bc776ef4046513540b8.tar.xz
rt.equinox.p2-7c9545086de9dda759cf3bc776ef4046513540b8.zip
Bug 509401 - Clean up ChecksumProducer's computeMD5(File)Y20170330-1000I20170329-2000
Combine all statements that throw exceptions into a single try/catch block and do not catch FileNotFoundException as we're catching its parent, IOException, already. Change-Id: I26c02a183e5d950a6e19c3e6187d6e54418c422e Signed-off-by: Mykola Nikishov <mn@mn.com.ua>
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/ChecksumProducer.java11
1 files changed, 3 insertions, 8 deletions
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/ChecksumProducer.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/ChecksumProducer.java
index a9c1c5a9f..4296a53fa 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/ChecksumProducer.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/ChecksumProducer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2016 IBM Corporation and others.
+ * Copyright (c) 2009, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -21,14 +21,9 @@ public class ChecksumProducer {
public static String computeMD5(File file) {
if (file == null || file.isDirectory() || !file.exists())
return null;
- MessageDigest md5Checker;
- try {
- md5Checker = MessageDigest.getInstance("MD5"); //$NON-NLS-1$
- } catch (NoSuchAlgorithmException e) {
- return null;
- }
InputStream fis = null;
try {
+ MessageDigest md5Checker = MessageDigest.getInstance("MD5"); //$NON-NLS-1$
fis = new BufferedInputStream(new FileInputStream(file));
int read = -1;
final int bufferSize = 4 * 1024;
@@ -44,7 +39,7 @@ public class ChecksumProducer {
buf.append(Integer.toHexString(digest[i] & 0xFF));
}
return buf.toString();
- } catch (FileNotFoundException e) {
+ } catch (NoSuchAlgorithmException e) {
return null;
} catch (IOException e) {
return null;

Back to the top