Skip to content

Commit f2e3a45

Browse files
committed
Fixes for guava version bump
1 parent 163e595 commit f2e3a45

6 files changed

Lines changed: 23 additions & 48 deletions

File tree

uPortal-rendering/src/main/java/org/apereo/portal/portlet/container/cache/CachingPortletOutputHandler.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515
package org.apereo.portal.portlet.container.cache;
1616

17-
import com.google.common.base.Function;
1817
import java.io.ByteArrayOutputStream;
1918
import java.io.IOException;
2019
import java.io.OutputStream;
@@ -102,14 +101,7 @@ public PrintWriter getPrintWriter() throws IOException {
102101
this.maximumSize,
103102
delegateWriter,
104103
this.cachingWriter,
105-
new Function<LimitingTeeWriter, Object>() {
106-
@Override
107-
public Object apply(LimitingTeeWriter input) {
108-
// Limit hit, clear the cache
109-
clearCachedWriter();
110-
return null;
111-
}
112-
});
104+
input -> clearCachedWriter());
113105

114106
// Wrap the limiting tee writer in a PrintWriter to return to the caller
115107
this.printWriter = new PrintWriter(this.teeWriter);
@@ -135,14 +127,7 @@ public OutputStream getOutputStream() throws IOException {
135127
this.maximumSize,
136128
delegateOutputStream,
137129
this.cachingOutputStream,
138-
new Function<LimitingTeeOutputStream, Object>() {
139-
@Override
140-
public Object apply(LimitingTeeOutputStream input) {
141-
// Limit hit, clear the cache
142-
clearCachedStream();
143-
return null;
144-
}
145-
});
130+
input -> clearCachedStream());
146131
}
147132

148133
return teeStream;

uPortal-rendering/src/main/java/org/apereo/portal/portlet/container/cache/LimitingTeeOutputStream.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
*/
1515
package org.apereo.portal.portlet.container.cache;
1616

17-
import com.google.common.base.Function;
1817
import java.io.IOException;
1918
import java.io.OutputStream;
19+
import java.util.function.Consumer;
2020
import org.apache.commons.io.output.NullOutputStream;
2121
import org.apereo.portal.utils.TeeOutputStream;
2222

@@ -29,7 +29,7 @@
2929
public class LimitingTeeOutputStream extends TeeOutputStream {
3030
private final long maximumBytes;
3131
private final OutputStream branch;
32-
private final Function<LimitingTeeOutputStream, ?> limitReachedCallback;
32+
private final Consumer<LimitingTeeOutputStream> limitReachedCallback;
3333
private long byteCount = 0;
3434
private boolean limitReached = false;
3535

@@ -41,7 +41,7 @@ public LimitingTeeOutputStream(
4141
long maximumBytes,
4242
OutputStream out,
4343
OutputStream branch,
44-
Function<LimitingTeeOutputStream, ?> limitReachedCallback) {
44+
Consumer<LimitingTeeOutputStream> limitReachedCallback) {
4545
super(out, branch);
4646
this.maximumBytes = maximumBytes;
4747
this.branch = branch;
@@ -81,7 +81,7 @@ protected void beforeWrite(int n) throws IOException {
8181
this.setBranch(NullOutputStream.NULL_OUTPUT_STREAM);
8282

8383
if (this.limitReachedCallback != null) {
84-
this.limitReachedCallback.apply(this);
84+
this.limitReachedCallback.accept(this);
8585
}
8686
}
8787
}

uPortal-rendering/src/main/java/org/apereo/portal/portlet/container/cache/LimitingTeeWriter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
*/
1515
package org.apereo.portal.portlet.container.cache;
1616

17-
import com.google.common.base.Function;
1817
import java.io.IOException;
1918
import java.io.Writer;
19+
import java.util.function.Consumer;
2020
import org.apache.commons.io.output.NullWriter;
2121
import org.apereo.portal.utils.TeeWriter;
2222

@@ -29,7 +29,7 @@
2929
public class LimitingTeeWriter extends TeeWriter {
3030
private final long maximumCharacters;
3131
private final Writer branch;
32-
private final Function<LimitingTeeWriter, ?> limitReachedCallback;
32+
private final Consumer<LimitingTeeWriter> limitReachedCallback;
3333
private long characterCount = 0;
3434
private boolean limitReached = false;
3535

@@ -41,7 +41,7 @@ public LimitingTeeWriter(
4141
long maximumCharacters,
4242
Writer out,
4343
Writer branch,
44-
Function<LimitingTeeWriter, ?> limitReachedCallback) {
44+
Consumer<LimitingTeeWriter> limitReachedCallback) {
4545
super(out, branch);
4646
this.maximumCharacters = maximumCharacters;
4747
this.branch = branch;
@@ -83,7 +83,7 @@ protected void beforeWrite(int n) throws IOException {
8383
this.setBranch(NullWriter.NULL_WRITER);
8484

8585
if (this.limitReachedCallback != null) {
86-
this.limitReachedCallback.apply(this);
86+
this.limitReachedCallback.accept(this);
8787
}
8888
}
8989
}

uPortal-webapp/src/test/java/org/apereo/portal/events/aggr/PortalRawEventsAggregatorImplTest.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,15 @@ public EventProcessingResult answer(InvocationOnMock invocation)
175175
new Answer<Boolean>() {
176176
@Override
177177
public Boolean answer(InvocationOnMock invocation) throws Throwable {
178-
((Function<PortalEvent, Boolean>) invocation.getArguments()[3])
179-
.apply(
180-
new MockPortalEvent(
181-
this,
182-
"serverName",
183-
"eventSessionId",
184-
person));
178+
Boolean ignored =
179+
((Function<PortalEvent, Boolean>)
180+
invocation.getArguments()[3])
181+
.apply(
182+
new MockPortalEvent(
183+
this,
184+
"serverName",
185+
"eventSessionId",
186+
person));
185187

186188
return false;
187189
}

uPortal-webapp/src/test/java/org/apereo/portal/portlet/container/cache/LimitingTeeOutputStreamTest.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import static junit.framework.Assert.assertTrue;
1919
import static org.junit.Assert.assertArrayEquals;
2020

21-
import com.google.common.base.Function;
2221
import java.io.ByteArrayOutputStream;
2322
import java.io.IOException;
2423
import java.util.Arrays;
@@ -66,13 +65,7 @@ public void testContentExceedsClearBuffer() throws IOException {
6665
content.length - 1,
6766
NullOutputStream.NULL_OUTPUT_STREAM,
6867
byteStream,
69-
new Function<LimitingTeeOutputStream, Object>() {
70-
@Override
71-
public Object apply(LimitingTeeOutputStream input) {
72-
byteStream.reset();
73-
return null;
74-
}
75-
});
68+
input -> byteStream.reset());
7669
// write the first few chars
7770
stream.write(content, 0, 5);
7871
// verify content successfully buffered

uPortal-webapp/src/test/java/org/apereo/portal/portlet/container/cache/LimitingTeeWriterTest.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515
package org.apereo.portal.portlet.container.cache;
1616

17-
import com.google.common.base.Function;
1817
import java.io.IOException;
1918
import org.apache.commons.io.output.NullWriter;
2019
import org.apache.commons.io.output.StringBuilderWriter;
@@ -60,13 +59,9 @@ public void testContentExceedsClearBuffer() throws IOException {
6059
content.length() - 1,
6160
NullWriter.NULL_WRITER,
6261
stringWriter,
63-
new Function<LimitingTeeWriter, Object>() {
64-
@Override
65-
public Object apply(LimitingTeeWriter input) {
66-
final StringBuilder builder = stringWriter.getBuilder();
67-
builder.delete(0, builder.length());
68-
return null;
69-
}
62+
input -> {
63+
final StringBuilder builder = stringWriter.getBuilder();
64+
builder.delete(0, builder.length());
7065
});
7166
// write the first few chars
7267
writer.write(content.substring(0, 5));

0 commit comments

Comments
 (0)