-
Notifications
You must be signed in to change notification settings - Fork 72
Closed
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
If a SecurityManager
is enabled in the JVM, the language detection does not work.
Sample code to reproduce the issue:
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import com.github.pemistahl.lingua.api.Language;
import com.github.pemistahl.lingua.api.LanguageDetector;
import com.github.pemistahl.lingua.api.LanguageDetectorBuilder;
public class SecurityManagerApp {
public static Language[] languages = new Language[] { Language.ENGLISH, Language.FRENCH};
public static void main(String[] args) throws IOException {
File policyFile = File.createTempFile("security", ".policy", null);
Files.write(policyFile.toPath(),
"grant { permission java.security.AllPermission; }; ".getBytes());
System.setProperty("java.security.policy", policyFile.getAbsolutePath());
System.setSecurityManager(new SecurityManager());
LanguageDetector detector = LanguageDetectorBuilder.fromLanguages(languages).build();
System.out.println(detector.detectLanguageOf("Comment ca va\r\n"
+ "Comme ci\r\n"
+ "Comme ci\r\n"
+ "Comme ci\r\n"
+ "Comme ca").name());
}
}
Note that in my use-case, I am creating a plugin for an application, so I cannot disable the SecurityManager of the JVM.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working