Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java b/bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java
index a83bed300..01977312b 100644
--- a/bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java
+++ b/bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 compeople AG and others.
+ * Copyright (c) 2007, 2018 compeople AG 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
@@ -26,13 +26,15 @@ public class ArtifactRepositoryMock implements InvocationHandler {
private String artifactResource;
public static IArtifactRepository getMock(String artifactResource) {
- return (IArtifactRepository) Proxy.newProxyInstance(IArtifactRepository.class.getClassLoader(), new Class[] {IArtifactRepository.class}, new ArtifactRepositoryMock(artifactResource));
+ return (IArtifactRepository) Proxy.newProxyInstance(IArtifactRepository.class.getClassLoader(),
+ new Class[] { IArtifactRepository.class }, new ArtifactRepositoryMock(artifactResource));
}
private ArtifactRepositoryMock(String artifactResource) {
this.artifactResource = artifactResource;
}
+ @Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (!method.getName().equals("getArtifact"))
throw new RuntimeException("Unexpected usage!");
@@ -41,9 +43,8 @@ public class ArtifactRepositoryMock implements InvocationHandler {
}
private IStatus getArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) {
- InputStream inputStream;
- try {
- inputStream = TestActivator.getContext().getBundle().getEntry(artifactResource).openStream();
+ try (InputStream inputStream = TestActivator.getContext().getBundle().getEntry(artifactResource)
+ .openStream();) {
FileUtils.copyStream(inputStream, true, destination, true);
return Status.OK_STATUS;
} catch (IOException e) {

Back to the top