Skip to content

Commit

Permalink
Reset inputUsed after processing to fix reusing opener
Browse files Browse the repository at this point in the history
A second open-http in a flux resulted in MalformedURLException,
see: https://gitlab.com/oersi/oersi-etl/-/merge_requests/284
  • Loading branch information
fsteeg committed Mar 10, 2023
1 parent 3d01453 commit dc636b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ public void process(final String input) {
catch (final IOException e) {
throw new MetafactureException(e);
}
finally {
inputUsed = false;
}
}

private String getInput(final String input, final String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;

import static org.mockito.Mockito.times;

import java.io.IOException;
import java.io.Reader;
import java.util.Arrays;
Expand Down Expand Up @@ -318,11 +320,15 @@ private void shouldPerformRequest(final String input, final HttpOpener.Method me
WireMock.stubFor(stub);

opener.process(String.format(input, baseUrl));

// use the opener a second time in a workflow:
opener.process(String.format(input, baseUrl));

opener.closeStream();

WireMock.verify(request);

Mockito.verify(receiver).process(processedObject.capture());
Mockito.verify(receiver, times(2)).process(processedObject.capture());
Assert.assertEquals(responseBody, ResourceUtil.readAll(processedObject.getValue()));
}

Expand Down

0 comments on commit dc636b8

Please sign in to comment.