I am using Javalin in my project now and faced a problem with the result(inputStream).
I have implemented a POST method where, based on the parameters, a PDF file is send back.
Problem now is, after the file is successfully uploaded, its locked and can not be deleted.
Thats the simple sample source:
ctx.result(FileUtils.openInputStream(new File("c:\tmp\test.pdf")));
ctx.status(200);
I also tried to use a FileInputStream with the close method after the status, but then error 500 is returned.
Also using the After Handler does not work.
Did I made something wrong?
Hi @kai83, could you make a small sample application which reproduces the problem? It seems that the code for closing input-streams has gone missing 馃
Hi @tipsy,
I am out of office now but will create a small application tomorrow morning.
In my tests I was only using the following code and could reproduce it:
Javalin webServer = Javalin.start(7000);
webServer.get("/file", ctx -> {
ctx.result(FileUtils.openInputStream(new File("c:\tmp\test.pdf")));
ctx.status(200);
});
After retrieving the file from my client, the test.pdf was locked and could not be deleted anymore.
Thank you for your quick reply and I will prepare a small application at first in the morning.
@kai83 I'll have a look now.
I've confirmed that the InputStream is not being closed properly, will fix it right away.
@kai83 It's been fixed now, will be part of the next release candidate for Javalin 2.0.
@tipsy
You are a star man!
Really cool... Many thanks!
May I ask when you plan to release the next RC? I saw V2 will not be backword compatible, is sample source on how to use "GET" and "POST" available as well?
I could not find them yet but will have a look today.
Again, many thanks for the fantastic and very quick support.
May I ask when you plan to release the next RC?
I just did:
Maven:
<dependency>
<groupId>io.javalin</groupId>
<artifactId>javalin</artifactId>
<version>2.0.0.RC1</version>
</dependency>
Gradle:
compile 'io.javalin:javalin:2.0.0.RC1'
May I ask when you plan to release the next RC? I saw V2 will not be backword compatible, is sample source on how to use "GET" and "POST" available as well?
I could not find them yet but will have a look today.
It's 95% backwards compatible, there is a migration guide here: https://github.com/tipsy/javalin/issues/240#issuecomment-395849357.
Again, many thanks for the fantastic and very quick support.
You're welcome, thank you for reporting the bug :)
@tipsy
Sorry to coming back on this.
Seems like the RC1 is not on Maven yet.
I can only get
Can you confirm please?
Many thanks!
Should be out, I'll check after lunch.
It's available: https://repo1.maven.org/maven2/io/javalin/javalin/
@tipsy
Hmmm strange. If I add the RC0 then it works. RC1 always shows an error.
And if you move to the web based Maven repository it also only shows RC0.
https://mvnrepository.com/artifact/io.javalin/javalin
But no problem I will wait to see if some replication is needed.
@tipsy
Found the problem...
I had to activate: "Force Update of Snapshots/Releases" in Eclipse.
Now its found and installed.
Again, many thanks!