-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
I am trying to run this code on groovy kernel and its give a strange error.
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
zipInputFile = new ZipFile(file)
list = entires.toList();
zipInputFile.getInputStream(list.get(0))
This is the exception it is giving. while running the same code works with normal execution of groovy script.
groovy.lang.MissingPropertyException: No such property: file for class: script1622875172283
at this cell line 3
at com.twosigma.beakerx.groovy.evaluator.GroovyCodeRunner.runScript(GroovyCodeRunner.java:94)
at com.twosigma.beakerx.groovy.evaluator.GroovyCodeRunner.call(GroovyCodeRunner.java:59)
at com.twosigma.beakerx.groovy.evaluator.GroovyCodeRunner.call(GroovyCodeRunner.java:32)
Later I found this is happening because this kernel don't share local variables across the cells. But it still share local variable declared at last line.
So if I write,
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
String file = "C:\\Users\\user\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.bcel\\bcel\\6.5.0\\79b1975ec0c7a6c1a15e19fb3a58cc4041b4aaea\\bcel-6.5.0.jar"
zipInputFile = new ZipFile(file);
in a separate cell 'zipInputFile' will be scoped to next cell.
But when I declare variable mentioning its type. (both ways are valid in groovy)
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
String file = "C:\\Users\\user\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.bcel\\bcel\\6.5.0\\79b1975ec0c7a6c1a15e19fb3a58cc4041b4aaea\\bcel-6.5.0.jar"
ZipFile zipInputFile = new ZipFile(file);
The zipInputFile will not get scoped to the next cell. Why is this inconsistency ?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels