diff --git a/build.gradle b/build.gradle index 30e429d..ee23597 100644 --- a/build.gradle +++ b/build.gradle @@ -2,11 +2,6 @@ if (project.hasProperty('overrideBuildEnvironment')) { // Otherwise, assume overrideBuildEnvironment defines a path to a file, and apply it. apply from: project.overrideBuildEnvironment } - -task wrapper(type: Wrapper) { - gradleVersion = '6.4' -} - buildscript { repositories { mavenCentral() @@ -17,14 +12,9 @@ buildscript { classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.+' } } -apply plugin: 'maven-publish' -apply plugin: 'com.jfrog.bintray' - - ext { libs = [:] } - libs += [ apache: "org.apache.commons:commons-lang3:3.4", apacheCommonsIo: "commons-io:commons-io:2.4", @@ -41,15 +31,14 @@ libs += [ restliServer: "com.linkedin.pegasus:restli-server:6.0.12", restliNettyStandalone: "com.linkedin.pegasus:restli-netty-standalone:6.0.12" ] - -allprojects { - version='0.0.5' +apply plugin: 'idea' +subprojects { + version='0.0.9' group='com.linkedin.flashback' - apply plugin: 'maven' apply plugin: 'maven-publish' + apply plugin: 'com.jfrog.bintray' apply plugin: 'java' - apply plugin: 'idea' dependencies { compile libs.apache @@ -64,21 +53,70 @@ allprojects { compile libs.log4j compile libs.netty testCompile libs.testng - } - repositories { mavenCentral() } - test { useTestNG() } + tasks.withType(Jar) { + from "$rootDir/LICENSE" + from "$rootDir/NOTICE" + } + task sourcesJar(type: Jar) { + classifier = 'sources' + from sourceSets.main.allSource + } + task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir + } + def pomConfig = { + licenses { + license { + name "2-CLAUSE BSD" + url "https://github.com/linkedin/flashback/blob/master/LICENSE" + distribution "repo" + } + } + scm { + url "https://github.com/linkedin/flashback.git" + } + } + + publishing { + publications { + MyPublication(MavenPublication) { + from components.java + artifact javadocJar + artifact sourcesJar + + pom.withXml { + def root = asNode() + root.appendNode('description', 'Mock the internet') + root.appendNode('name', 'flashback') + root.children().last() + pomConfig + } + + } + } + } + bintray { + user = System.getenv('BINTRAY_USER') + key = System.getenv('BINTRAY_API_KEY') + publications = ['MyPublication'] + pkg { + repo = 'maven' + userOrg = 'linkedin' + name = 'flashback' + vcsUrl = 'https://github.com/linkedin/flashback.git' + } + } } project(':flashback-test-util') { println "Building project 'test-util'" - dependencies { compile project(':flashback-core-impl') compile project(':flashback-smartproxy') @@ -86,34 +124,26 @@ project(':flashback-test-util') { compile libs.testng } } - project(':flashback-smartproxy') { println "Building project 'smartproxy'" - dependencies { compile project(':flashback-core-impl') compile project(':flashback-netty') compile project(':mitm') } } - project(':flashback-netty') { println "Building project 'netty'" - dependencies { compile project(':flashback-core-impl') } } - project(':flashback-admin') { - apply plugin: 'java' - dependencies { compile libs.restliServer compile libs.restliNettyStandalone compile project(':flashback-smartproxy') } - task startAdminServer(type: JavaExec) { main = 'com.linkedin.restli.server.NettyStandaloneLauncher' if (project.hasProperty('Args')) { @@ -124,7 +154,6 @@ project(':flashback-admin') { standardInput = System.in } } - project(':flashback-all') { dependencies { // this is a meta project that depends on all of the "entry-point" subprojects to make it easier to pull in the @@ -136,65 +165,4 @@ project(':flashback-all') { compile project(':flashback-netty') compile project(':flashback-admin') } -} - - -tasks.withType(Jar) { - from "$rootDir/LICENSE" - from "$rootDir/NOTICE" -} - -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -def pomConfig = { - licenses { - license { - name "2-CLAUSE BSD" - url "https://github.com/linkedin/flashback/blob/master/LICENSE" - distribution "repo" - } - } - - scm { - url 'https://github.com/linkedin/flashback.git' - - } -} - - -publishing { - publications { - MyPublication(MavenPublication) { - from components.java - artifact javadocJar - artifact sourcesJar - - pom.withXml { - def root = asNode() - root.appendNode('name', 'flashback') - root.children().last() + pomConfig - } - } - } -} - -bintray { - user = System.getenv('BINTRAY_USER') - key = System.getenv('BINTRAY_API_KEY') - publications = ['MyPublication'] - pkg { - repo = 'maven' - userOrg = 'linkedin' - name = 'flashback' - - vcsUrl = 'https://github.com/linkedin/flashback.git' - } } \ No newline at end of file diff --git a/flashback-core-impl/src/main/java/com/linkedin/flashback/http/HttpUtilities.java b/flashback-core-impl/src/main/java/com/linkedin/flashback/http/HttpUtilities.java index b343653..83533cf 100644 --- a/flashback-core-impl/src/main/java/com/linkedin/flashback/http/HttpUtilities.java +++ b/flashback-core-impl/src/main/java/com/linkedin/flashback/http/HttpUtilities.java @@ -64,7 +64,7 @@ static public boolean isCompressedContentEncoding(String encodingName) { /** * Converts a URL / POST parameter string to an ordered map of key / value pairs - * @param paramsString the URL-encoded &-delimited string of key / value pairs + * @param paramsString the URL-encoded '&' delimited string of key / value pairs * @return a LinkedHashMap representing the decoded parameters */ static public Map stringToUrlParams(String paramsString, String charset) @@ -87,7 +87,7 @@ static public Map stringToUrlParams(String paramsString, String /** * Converts an ordered map of key / value pairs to a URL parameter string * @param params the map of key / value pairs - * @return a string representation of the key / value pairs, delimited by '&' + * @return a string representation of the key / value pairs, delimited by '&' */ static public String urlParamsToString(Map params, String charset) throws UnsupportedEncodingException { diff --git a/flashback-netty/src/main/java/com/linkedin/flashback/netty/builder/RecordedHttpMessageBuilder.java b/flashback-netty/src/main/java/com/linkedin/flashback/netty/builder/RecordedHttpMessageBuilder.java index 601b3a4..75930c5 100644 --- a/flashback-netty/src/main/java/com/linkedin/flashback/netty/builder/RecordedHttpMessageBuilder.java +++ b/flashback-netty/src/main/java/com/linkedin/flashback/netty/builder/RecordedHttpMessageBuilder.java @@ -118,7 +118,7 @@ protected String getCharset() { } /** - * Build serializable {@Link RecordedHttpBody} using temporary byte buffers. + * Build serializable {@link RecordedHttpBody} using temporary byte buffers. * Based on Charset, we will build concrete Http body either binary or characters. * TODO: throw customized exception if failed to create http body * diff --git a/flashback-test-util/src/main/java/com/linkedin/flashback/test/FlashbackBaseTest.java b/flashback-test-util/src/main/java/com/linkedin/flashback/test/FlashbackBaseTest.java index d75b843..7ab0aa0 100644 --- a/flashback-test-util/src/main/java/com/linkedin/flashback/test/FlashbackBaseTest.java +++ b/flashback-test-util/src/main/java/com/linkedin/flashback/test/FlashbackBaseTest.java @@ -72,7 +72,7 @@ protected void flashbackGlobalCleanUp() { } /** - * this is the place to override and change the default scene & matchrule on each test class. + * this is the place to override and change the default scene & matchrule on each test class. * * @throws IOException */ @@ -291,7 +291,7 @@ private void determineDefaultSettings() _defaultScene = SceneFactory.create(sceneConfiguration); } - // after determined the default Scene&MatchRule for this test class, set them. + // after determined the default Scene & MatchRule for this test class, set them. _flashbackRunner.setScene(_defaultScene); _flashbackRunner.setMatchRule(_defaultMatchRule); } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index b5166da..c44b679 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 81f7881..0526ee2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Wed Oct 26 12:30:45 EDT 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-bin.zip diff --git a/gradlew b/gradlew index 91a7e26..cccdd3d 100755 --- a/gradlew +++ b/gradlew @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh ############################################################################## ## @@ -6,20 +6,38 @@ ## ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -30,6 +48,7 @@ die ( ) { cygwin=false msys=false darwin=false +nonstop=false case "`uname`" in CYGWIN* ) cygwin=true @@ -40,31 +59,11 @@ case "`uname`" in MINGW* ) msys=true ;; + NONSTOP* ) + nonstop=true + ;; esac -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -90,7 +89,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then @@ -114,6 +113,7 @@ fi if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` @@ -154,11 +154,19 @@ if $cygwin ; then esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " } -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 8a0b282..e95643d 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,90 +1,84 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/mitm/src/main/java/com/linkedin/mitm/factory/CertificateKeyStoreFactory.java b/mitm/src/main/java/com/linkedin/mitm/factory/CertificateKeyStoreFactory.java index 1cad12e..5eb2e59 100644 --- a/mitm/src/main/java/com/linkedin/mitm/factory/CertificateKeyStoreFactory.java +++ b/mitm/src/main/java/com/linkedin/mitm/factory/CertificateKeyStoreFactory.java @@ -25,7 +25,7 @@ /** - * This factory would be used to generate {@Link KeyStore} either from CA certificate + * This factory would be used to generate {@link KeyStore} either from CA certificate * or server identity certificates * It will be only used to generate keyManagers not trustManagers. * diff --git a/mitm/src/main/java/com/linkedin/mitm/proxy/channel/ChannelHandlerDelegate.java b/mitm/src/main/java/com/linkedin/mitm/proxy/channel/ChannelHandlerDelegate.java index 35b7b0f..39c7067 100644 --- a/mitm/src/main/java/com/linkedin/mitm/proxy/channel/ChannelHandlerDelegate.java +++ b/mitm/src/main/java/com/linkedin/mitm/proxy/channel/ChannelHandlerDelegate.java @@ -10,7 +10,7 @@ /** * Interface to create Handler delegate which will - * be used by {@Link ClientChannelHandler} + * be used by {@link ClientChannelHandler} * * @author shfeng . */