One2OneBidiFlow $ OutputTruncationException on GET Request

@jrudolph I am getting the same exception. I will put the snippet below:

`
public HttpResponse handleRequest(HttpRequest request) throws InterruptedException,ExecutionException{
if (request.getUri().path().equals("/hey")) {
MerchantInfo info = authenticate(request);
System.out.println(“after auth:”+info);
UUID key = UUID.randomUUID();
System.out.println(“after auth key:”+info);
cache.put(key.toString(), info);
return HttpResponse.create().withEntity(ContentTypes.TEXT_PLAIN_UTF8, key.toString());
}else {
return HttpResponse.create().withStatus(404);
}
}

public void startWSServer(ActorSystem system, InetSocketAddress serverAddress, boolean useSSL) {
final Materializer materializer = ActorMaterializer.create(system);
final Http http = Http.get(system);
if(useSSL) {
log.info(“using ssl”);
http.setDefaultServerHttpContext(useHttps());//enables ssl
}

	final Function<HttpRequest, HttpResponse> handler = request -> handleRequest(request);

	CompletionStage<ServerBinding> serverBindingFuture =
			http
			.bindAndHandleSync(
					handler, ConnectHttp.toHost(serverAddress.getHostString(), serverAddress.getPort()),
					materializer);

	try{
		serverBindingFuture.toCompletableFuture().get(1, TimeUnit.SECONDS);
	}catch(TimeoutException|ExecutionException|InterruptedException e) {
		log.error("Exception: " + e.getMessage());
	}
	log.info("WS Server Listening on "+ serverAddress.getAddress());

}

private MerchantInfo authenticate(HttpRequest request) {
HttpHeader authHeader = request.getHeader(“Authorization”).orElse(null);
MerchantInfo info = null;
System.out.println(“in auth:”+request);
if(authHeader != null) {
System.out.println(" auth not null:"+authHeader);
String decryptedToken = decryptAuthBasicToken(authHeader.value());
int separatorPos = decryptedToken.indexOf(’:’);
String apiKey = decryptedToken.substring(0,separatorPos);
String apiPass = decryptedToken.substring(separatorPos + 1);
System.out.println(“key:”+apiKey +" pass:"+apiPass);
info = db.getRecord(dbMerchantInfoCollection, keyT, apiPass, keyM, apiKey, MerchantInfo.class);
}
return info;
}
private static String decryptAuthBasicToken(String token) {
return new String(Base64.getDecoder().decode(token), StandardCharsets.UTF_8);
}
`

The call doesn’t execute half of the code in authenticate method.

`
Internal server error, sending 500 response
akka.http.impl.util.One2OneBidiFlow$OutputTruncationException: Inner flow was completed without producing result elements for 1 outstanding elements
at akka.http.impl.util.One2OneBidiFlow$OutputTruncationException$.apply(One2OneBidiFlow.scala:22)
at akka.http.impl.util.One2OneBidiFlow$OutputTruncationException$.apply(One2OneBidiFlow.scala:22)
at akka.http.impl.util.One2OneBidiFlow$One2OneBidi$$anon$1$$anon$4.onUpstreamFinish(One2OneBidiFlow.scala:97)
at akka.stream.impl.fusing.GraphInterpreter.processEvent(GraphInterpreter.scala:506)
at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:376)
at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:606)
at akka.stream.impl.fusing.GraphInterpreterShell$AsyncInput.execute(ActorGraphInterpreter.scala:485)
at akka.stream.impl.fusing.GraphInterpreterShell.processEvent(ActorGraphInterpreter.scala:581)
at akka.stream.impl.fusing.ActorGraphInterpreter.akka$stream$impl$fusing$ActorGraphInterpreter$$processEvent(ActorGraphInterpreter.scala:749)
at akka.stream.impl.fusing.ActorGraphInterpreter$$anonfun$receive$1.applyOrElse(ActorGraphInterpreter.scala:764)
at akka.actor.Actor.aroundReceive(Actor.scala:539)
at akka.actor.Actor.aroundReceive$(Actor.scala:537)
at akka.stream.impl.fusing.ActorGraphInterpreter.aroundReceive(ActorGraphInterpreter.scala:671)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:612)
at akka.actor.ActorCell.invoke(ActorCell.scala:581)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:268)
at akka.dispatch.Mailbox.run(Mailbox.scala:229)
at akka.dispatch.Mailbox.exec(Mailbox.scala:241)
at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

`

@jrudolph I faced similar exception and co-incidentally the cause of this exception is always traceless. I had to literally debug line by line to find the issue. The issue was related to Base64 to utf conversion bug.

Thanks anyways for always being there to support us. :slight_smile: