[ https://issues.apache.org/jira/browse/KAFKA-4247?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16319345#comment-16319345 ]
ASF GitHub Bot commented on KAFKA-4247: --------------------------------------- junrao closed pull request #4406: KAFKA-4247: Prevent CLASSPATH from beginning with a single colon URL: https://github.com/apache/kafka/pull/4406 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/bin/kafka-run-class.sh b/bin/kafka-run-class.sh index fc89f25d9d2..6676d0d2156 100755 --- a/bin/kafka-run-class.sh +++ b/bin/kafka-run-class.sh @@ -59,11 +59,7 @@ fi shopt -s nullglob for dir in "$base_dir"/core/build/dependant-libs-${SCALA_VERSION}*; do - if [ -z "$CLASSPATH" ] ; then - CLASSPATH="$dir/*" - else - CLASSPATH="$CLASSPATH:$dir/*" - fi + CLASSPATH="$CLASSPATH:$dir/*" done for file in "$base_dir"/examples/build/libs/kafka-examples*.jar; @@ -260,6 +256,11 @@ if [ "x$GC_LOG_ENABLED" = "xtrue" ]; then fi fi +# Remove a possible colon prefix from the classpath (happens at lines like `CLASSPATH="$CLASSPATH:$file"` when CLASSPATH is blank) +# Syntax used on the right side is native Bash string manipulation; for more details see +# http://tldp.org/LDP/abs/html/string-manipulation.html, specifically the section titled "Substring Removal" +CLASSPATH=${CLASSPATH#:} + # If Cygwin is detected, classpath is converted to Windows format. (( CYGWIN )) && CLASSPATH=$(cygpath --path --mixed "${CLASSPATH}") ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > kafka-run-class has potential to add a leading colon to classpath > ----------------------------------------------------------------- > > Key: KAFKA-4247 > URL: https://issues.apache.org/jira/browse/KAFKA-4247 > Project: Kafka > Issue Type: Bug > Components: KafkaConnect > Reporter: Ryan P > Assignee: Ryan P > Fix For: 1.1.0 > > > https://github.com/confluentinc/kafka/blob/trunk/bin/kafka-run-class.sh#L128-L133 > In the event CLASSPATH has not yet been populated this will result in > :$file > Normally this wouldn't be a problem however Connect's AbstractClassHearder > uses ClasspathHelper.forJavaClassPath() to collect it's eligible classes. > With a leading colon you will endup with a entry for null which is expanded > to the working directory. > java -cp ":" test > [] > java -cp ":Users" test > [file:/Users/ryan/, file:/Users/ryan/Users] > This is problematic if the script was run from the root directory since the > URLs will be scanned the directories recursively. Ultimately leading to a > situation where the entire FileSystem is scanned. This has been known to > cause issues for some Docker installations. > Typically this is worked around by editing the the kafka-run-class script > however I think we should handle this within Connect itself by excluding the > root directory. > -- This message was sent by Atlassian JIRA (v6.4.14#64029)