On Mon, Apr 6, 2020 at 3:34 PM <[email protected]> wrote:
> This is an automated email from the ASF dual-hosted git repository.
>
> ebourg pushed a commit to branch master
> in repository
> https://gitbox.apache.org/repos/asf/tomcat-jakartaee-migration.git
>
> commit 29ea1891489060f3b3e40259098def5ae47645ef
> Author: Emmanuel Bourg <[email protected]>
> AuthorDate: Mon Apr 6 15:24:35 2020 +0200
>
> Replaced NonClosing{In,Out}putStream with the equivalent classes from
> Commons IO
>
Ah, the beauty of having Maven. Actual benefit: zero. Trouble with updating
dependencies: one. Possible incompatibilities: one.
So I think it's a total of -2 for the commit.
Rémy
> ---
> pom.xml | 5 ++
> .../org/apache/tomcat/jakartaee/Migration.java | 7 +-
> .../tomcat/jakartaee/NonClosingInputStream.java | 84
> ----------------------
> .../tomcat/jakartaee/NonClosingOutputStream.java | 60 ----------------
> 4 files changed, 10 insertions(+), 146 deletions(-)
>
> diff --git a/pom.xml b/pom.xml
> index cf7f18b..ab74cfe 100644
> --- a/pom.xml
> +++ b/pom.xml
> @@ -71,6 +71,11 @@
> <artifactId>bcel</artifactId>
> <version>6.4.1</version>
> </dependency>
> + <dependency>
> + <groupId>commons-io</groupId>
> + <artifactId>commons-io</artifactId>
> + <version>2.6</version>
> + </dependency>
> </dependencies>
>
> <build>
> diff --git a/src/main/java/org/apache/tomcat/jakartaee/Migration.java
> b/src/main/java/org/apache/tomcat/jakartaee/Migration.java
> index 734ebd8..5d8fdf1 100644
> --- a/src/main/java/org/apache/tomcat/jakartaee/Migration.java
> +++ b/src/main/java/org/apache/tomcat/jakartaee/Migration.java
> @@ -36,6 +36,9 @@ import java.util.jar.Manifest;
> import java.util.logging.Level;
> import java.util.logging.Logger;
>
> +import org.apache.commons.io.input.CloseShieldInputStream;
> +import org.apache.commons.io.output.CloseShieldOutputStream;
> +
> public class Migration {
>
> private static final Logger logger =
> Logger.getLogger(Migration.class.getCanonicalName());
> @@ -131,8 +134,8 @@ public class Migration {
>
> private boolean migrateArchive(InputStream src, OutputStream dest)
> throws IOException {
> boolean result = true;
> - try (JarInputStream jarIs = new JarInputStream(new
> NonClosingInputStream(src));
> - JarOutputStream jarOs = new JarOutputStream(new
> NonClosingOutputStream(dest))) {
> + try (JarInputStream jarIs = new JarInputStream(new
> CloseShieldInputStream(src));
> + JarOutputStream jarOs = new JarOutputStream(new
> CloseShieldOutputStream(dest))) {
> Manifest manifest = jarIs.getManifest();
> if (manifest != null) {
> // Make a safe copy to leave original manifest untouched.
> diff --git
> a/src/main/java/org/apache/tomcat/jakartaee/NonClosingInputStream.java
> b/src/main/java/org/apache/tomcat/jakartaee/NonClosingInputStream.java
> deleted file mode 100644
> index 53f883c..0000000
> --- a/src/main/java/org/apache/tomcat/jakartaee/NonClosingInputStream.java
> +++ /dev/null
> @@ -1,84 +0,0 @@
> -/*
> - * Licensed to the Apache Software Foundation (ASF) under one or more
> - * contributor license agreements. See the NOTICE file distributed with
> - * this work for additional information regarding copyright ownership.
> - * The ASF licenses this file to You under the Apache License, Version 2.0
> - * (the "License"); you may not use this file except in compliance with
> - * the License. You may obtain a copy of the License at
> - *
> - * http://www.apache.org/licenses/LICENSE-2.0
> - *
> - * Unless required by applicable law or agreed to in writing, software
> - * distributed under the License is distributed on an "AS IS" BASIS,
> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> - * See the License for the specific language governing permissions and
> - * limitations under the License.
> - */
> -package org.apache.tomcat.jakartaee;
> -
> -import java.io.IOException;
> -import java.io.InputStream;
> -
> -public class NonClosingInputStream extends InputStream {
> -
> - private InputStream wrapped;
> -
> -
> - public NonClosingInputStream(InputStream wrapped) {
> - this.wrapped = wrapped;
> - }
> -
> -
> - @Override
> - public int read() throws IOException {
> - return wrapped.read();
> - }
> -
> -
> - @Override
> - public int read(byte[] b) throws IOException {
> - return wrapped.read(b);
> - }
> -
> -
> - @Override
> - public int read(byte[] b, int off, int len) throws IOException {
> - return wrapped.read(b, off, len);
> - }
> -
> -
> - @Override
> - public long skip(long n) throws IOException {
> - return wrapped.skip(n);
> - }
> -
> -
> - @Override
> - public int available() throws IOException {
> - return wrapped.available();
> - }
> -
> -
> - @Override
> - public void close() throws IOException {
> - // NO-OP
> - }
> -
> -
> - @Override
> - public synchronized void mark(int readlimit) {
> - wrapped.mark(readlimit);
> - }
> -
> -
> - @Override
> - public synchronized void reset() throws IOException {
> - wrapped.reset();
> - }
> -
> -
> - @Override
> - public boolean markSupported() {
> - return wrapped.markSupported();
> - }
> -}
> diff --git
> a/src/main/java/org/apache/tomcat/jakartaee/NonClosingOutputStream.java
> b/src/main/java/org/apache/tomcat/jakartaee/NonClosingOutputStream.java
> deleted file mode 100644
> index b4ee198..0000000
> --- a/src/main/java/org/apache/tomcat/jakartaee/NonClosingOutputStream.java
> +++ /dev/null
> @@ -1,60 +0,0 @@
> -/*
> - * Licensed to the Apache Software Foundation (ASF) under one or more
> - * contributor license agreements. See the NOTICE file distributed with
> - * this work for additional information regarding copyright ownership.
> - * The ASF licenses this file to You under the Apache License, Version 2.0
> - * (the "License"); you may not use this file except in compliance with
> - * the License. You may obtain a copy of the License at
> - *
> - * http://www.apache.org/licenses/LICENSE-2.0
> - *
> - * Unless required by applicable law or agreed to in writing, software
> - * distributed under the License is distributed on an "AS IS" BASIS,
> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> - * See the License for the specific language governing permissions and
> - * limitations under the License.
> - */
> -package org.apache.tomcat.jakartaee;
> -
> -import java.io.IOException;
> -import java.io.OutputStream;
> -
> -public class NonClosingOutputStream extends OutputStream {
> -
> - private OutputStream wrapped;
> -
> -
> - public NonClosingOutputStream(OutputStream wrapped) {
> - this.wrapped = wrapped;
> - }
> -
> -
> - @Override
> - public void write(int b) throws IOException {
> - wrapped.write(b);
> - }
> -
> -
> - @Override
> - public void write(byte[] b) throws IOException {
> - wrapped.write(b);
> - }
> -
> -
> - @Override
> - public void write(byte[] b, int off, int len) throws IOException {
> - wrapped.write(b, off, len);
> - }
> -
> -
> - @Override
> - public void flush() throws IOException {
> - wrapped.flush();
> - }
> -
> -
> - @Override
> - public void close() throws IOException {
> - // NO-OP
> - }
> -}
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>