Skip to content

Commit 195a23a

Browse files
author
Vladimir Kotal
committed
read single line, fix the @ handling
1 parent 60540ec commit 195a23a

File tree

1 file changed

+7
-2
lines changed
  • opengrok-indexer/src/main/java/org/opengrok/indexer/index

1 file changed

+7
-2
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/index/Indexer.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,18 @@
2424
*/
2525
package org.opengrok.indexer.index;
2626

27+
import java.io.BufferedReader;
2728
import java.io.File;
29+
import java.io.FileInputStream;
2830
import java.io.IOException;
31+
import java.io.InputStreamReader;
2932
import java.io.PrintStream;
3033
import java.io.UncheckedIOException;
3134
import java.lang.reflect.Field;
3235
import java.lang.reflect.InvocationTargetException;
3336
import java.net.URI;
3437
import java.net.URISyntaxException;
38+
import java.nio.charset.StandardCharsets;
3539
import java.nio.file.Files;
3640
import java.nio.file.Path;
3741
import java.nio.file.Paths;
@@ -767,8 +771,9 @@ public static String[] parseOptions(String[] argv) throws ParseException {
767771
execute(optarg -> {
768772
String value = ((String) optarg).trim();
769773
if (value.startsWith("@")) {
770-
try {
771-
String token = new String(Files.readAllBytes(Path.of(value))).trim();
774+
try (BufferedReader in = new BufferedReader(new InputStreamReader(
775+
new FileInputStream(Path.of(value).toString().substring(1))))) {
776+
String token = in.readLine().trim();
772777
cfg.setIndexerAuthenticationToken(token);
773778
} catch (IOException e) {
774779
die("Failed to read from " + value);

0 commit comments

Comments
 (0)