mirror of
https://github.com/google/guava.git
synced 2024-10-23 08:44:54 +08:00
Remove a couple more obsolete workarounds for FilterOutputStream
trouble.
See https://github.com/google/guava/issues/1330. I have the others taken care of in cl/687314611. PiperOrigin-RevId: 688191691
This commit is contained in:
parent
9911c8347f
commit
79c9e7a36c
@ -99,8 +99,15 @@ public abstract class ByteSink {
|
||||
public void write(byte[] bytes) throws IOException {
|
||||
checkNotNull(bytes);
|
||||
|
||||
try (OutputStream out = openStream()) {
|
||||
Closer closer = Closer.create();
|
||||
try {
|
||||
OutputStream out = closer.register(openStream());
|
||||
out.write(bytes);
|
||||
out.flush(); // https://github.com/google/guava/issues/1330
|
||||
} catch (Throwable e) {
|
||||
throw closer.rethrow(e);
|
||||
} finally {
|
||||
closer.close();
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,8 +122,16 @@ public abstract class ByteSink {
|
||||
public long writeFrom(InputStream input) throws IOException {
|
||||
checkNotNull(input);
|
||||
|
||||
try (OutputStream out = openStream()) {
|
||||
return ByteStreams.copy(input, out);
|
||||
Closer closer = Closer.create();
|
||||
try {
|
||||
OutputStream out = closer.register(openStream());
|
||||
long written = ByteStreams.copy(input, out);
|
||||
out.flush(); // https://github.com/google/guava/issues/1330
|
||||
return written;
|
||||
} catch (Throwable e) {
|
||||
throw closer.rethrow(e);
|
||||
} finally {
|
||||
closer.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,8 +92,15 @@ public abstract class CharSink {
|
||||
public void write(CharSequence charSequence) throws IOException {
|
||||
checkNotNull(charSequence);
|
||||
|
||||
try (Writer out = openStream()) {
|
||||
Closer closer = Closer.create();
|
||||
try {
|
||||
Writer out = closer.register(openStream());
|
||||
out.append(charSequence);
|
||||
out.flush(); // https://github.com/google/guava/issues/1330
|
||||
} catch (Throwable e) {
|
||||
throw closer.rethrow(e);
|
||||
} finally {
|
||||
closer.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,8 +99,15 @@ public abstract class ByteSink {
|
||||
public void write(byte[] bytes) throws IOException {
|
||||
checkNotNull(bytes);
|
||||
|
||||
try (OutputStream out = openStream()) {
|
||||
Closer closer = Closer.create();
|
||||
try {
|
||||
OutputStream out = closer.register(openStream());
|
||||
out.write(bytes);
|
||||
out.flush(); // https://github.com/google/guava/issues/1330
|
||||
} catch (Throwable e) {
|
||||
throw closer.rethrow(e);
|
||||
} finally {
|
||||
closer.close();
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,8 +122,16 @@ public abstract class ByteSink {
|
||||
public long writeFrom(InputStream input) throws IOException {
|
||||
checkNotNull(input);
|
||||
|
||||
try (OutputStream out = openStream()) {
|
||||
return ByteStreams.copy(input, out);
|
||||
Closer closer = Closer.create();
|
||||
try {
|
||||
OutputStream out = closer.register(openStream());
|
||||
long written = ByteStreams.copy(input, out);
|
||||
out.flush(); // https://github.com/google/guava/issues/1330
|
||||
return written;
|
||||
} catch (Throwable e) {
|
||||
throw closer.rethrow(e);
|
||||
} finally {
|
||||
closer.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,8 +94,15 @@ public abstract class CharSink {
|
||||
public void write(CharSequence charSequence) throws IOException {
|
||||
checkNotNull(charSequence);
|
||||
|
||||
try (Writer out = openStream()) {
|
||||
Closer closer = Closer.create();
|
||||
try {
|
||||
Writer out = closer.register(openStream());
|
||||
out.append(charSequence);
|
||||
out.flush(); // https://github.com/google/guava/issues/1330
|
||||
} catch (Throwable e) {
|
||||
throw closer.rethrow(e);
|
||||
} finally {
|
||||
closer.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user