Is this expected? This code works in CF - if the...
# lucee
j
Is this expected? This code works in CF - if the file isn't there it sets an empty struct. In Lucee it bombs with 'file not found'. I can rewrite it with a FileExists() check but seems like the try/catch should handle that?
Copy code
try {
		application.stats = FileRead("/etc/stats.json");
	} catch (Any e) {
		application.stats = StructNew();
	}
z
does it throw outside a try catch?
ah does catch() work different?
also state version or it didn't happen 🙂
j
On latest 6.2.1.122 Seems to throw the same error outside the try catch as well... The 'type' seems weird:
type	string	expression
In CF I get
type java.io.FileNotFoundException
z
let me try locally
image.png
i agree the type expression is odd, please file a bug
👍 1
Saw your ticket comment about not able to reproduce? Let me spin up a CommandBox instance and see what I get with just this code. This damn wacky app is breaking all over the place 😕
d
@Jim Priest, Is the "stats.json" an empty string by any chance? There's a change in the behavior of
deserializeJSON()
and it will now throw an exception if the input is an empty string. My suspicion is the file is coming back empty, so it's not the
fileRead()
that's the problem (which would explain the
expression
exception. However, it should certainly be catching both errors. You might try splitting things up to see if you can determine if the problem is really with file reading or the deserializing.
j
@dswitzer Thanks! I think it's an issue with our application - I reproduced this in a Commandbox instance and it works correctly with no file present. I'm trying to convert our app over to Lucee so I'm guessing something is wacky when it's spinning up causing these weird errors - I just haven't found it yet LOL