Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
java-version: '21'
check-latest: true
cache: 'maven'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
java-version: '21'
check-latest: true
cache: 'maven'
- uses: vapier/coverity-scan-action@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/javadoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
java-version: '21'
check-latest: true
- name: Build Javadoc
run: mvn -B -V javadoc:javadoc --file pom.xml
run: ./mvnw -B -V -e javadoc:javadoc
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: ['8', '11', '17']
java: ['8', '11', '17', '21']
steps:
- uses: actions/checkout@v4
- name: Cache local Maven repository
Expand All @@ -31,10 +31,10 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
java-version: '21'
check-latest: true
- name: Build with Maven
run: mvn -B -V -DskipTests=true package --file pom.xml
run: ./mvnw -B -V -e -DskipTests=true package
- uses: actions/upload-artifact@v3
with:
name: java-${{ matrix.java }}-jars
Expand All @@ -49,7 +49,7 @@ jobs:
java-version: ${{ matrix.java }}
check-latest: true
- name: Test with Maven
run: mvn -B -V -P coverage verify -Denforcer.skip=true -Dmaven.resources.skip=true -Dmaven.main.skip=true -Dassembly.skipAssembly=true -Dmaven.javadoc.skip=true -DskipITs=false --file pom.xml
run: ./mvnw -B -V -e -P coverage verify -Denforcer.skip=true -Dmaven.resources.skip=true -Dmaven.main.skip=true -Dassembly.skipAssembly=true -Dmaven.javadoc.skip=true -DskipITs=false
- uses: actions/upload-artifact@v3
with:
name: java-${{ matrix.java }}-testresults
Expand Down
2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
17 changes: 16 additions & 1 deletion src/main/java/com/jcraft/jsch/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ static Channel getChannel(String type, Session session) {
ret = new ChannelForwardedTCPIP();
}
if (type.equals("sftp")) {
ret = new ChannelSftp();
ChannelSftp sftp = new ChannelSftp();
boolean useWriteFlushWorkaround =
session.getConfig("use_sftp_write_flush_workaround").equals("yes");
sftp.setUseWriteFlushWorkaround(useWriteFlushWorkaround);
ret = sftp;
}
if (type.equals("subsystem")) {
ret = new ChannelSubsystem();
Expand Down Expand Up @@ -204,6 +208,11 @@ public void setExtOutputStream(OutputStream out, boolean dontclose) {
}

public InputStream getInputStream() throws IOException {
Session _session = this.session;
if (_session != null && isConnected() && _session.getLogger().isEnabled(Logger.WARN)) {
_session.getLogger().log(Logger.WARN, "getInputStream() should be called before connect()");
}

int max_input_buffer_size = 32 * 1024;
try {
max_input_buffer_size = Integer.parseInt(getSession().getConfig("max_input_buffer_size"));
Expand All @@ -217,6 +226,12 @@ public InputStream getInputStream() throws IOException {
}

public InputStream getExtInputStream() throws IOException {
Session _session = this.session;
if (_session != null && isConnected() && _session.getLogger().isEnabled(Logger.WARN)) {
_session.getLogger().log(Logger.WARN,
"getExtInputStream() should be called before connect()");
}

int max_input_buffer_size = 32 * 1024;
try {
max_input_buffer_size = Integer.parseInt(getSession().getConfig("max_input_buffer_size"));
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/jcraft/jsch/ChannelSftp.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ public class ChannelSftp extends ChannelSession {
private Charset fEncoding = StandardCharsets.UTF_8;
private boolean fEncoding_is_utf8 = true;

private boolean useWriteFlushWorkaround = true;

private RequestQueue rq = new RequestQueue(16);

/**
Expand All @@ -181,6 +183,14 @@ public int getBulkRequests() {
return rq.size();
}

public void setUseWriteFlushWorkaround(boolean useWriteFlushWorkaround) {
this.useWriteFlushWorkaround = useWriteFlushWorkaround;
}

public boolean getUseWriteFlushWorkaround() {
return useWriteFlushWorkaround;
}

public ChannelSftp() {
super();
lwsize_max = LOCAL_WINDOW_SIZE_MAX;
Expand Down Expand Up @@ -754,6 +764,9 @@ public void write(byte[] d, int s, int len) throws IOException {
try {
int _len = len;
while (_len > 0) {
if (useWriteFlushWorkaround && rwsize < 21 + handle.length + _len + 4) {
flush();
}
int sent = sendWRITE(handle, _offset[0], d, s, _len);
writecount++;
_offset[0] += sent;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/jcraft/jsch/JSch.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ public class JSch {
config.put("try_additional_pubkey_algorithms",
Util.getSystemProperty("jsch.try_additional_pubkey_algorithms", "yes"));
config.put("enable_auth_none", Util.getSystemProperty("jsch.enable_auth_none", "yes"));
config.put("use_sftp_write_flush_workaround",
Util.getSystemProperty("jsch.use_sftp_write_flush_workaround", "yes"));

config.put("CheckCiphers",
Util.getSystemProperty("jsch.check_ciphers", "chacha20-poly1305@openssh.com"));
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/jcraft/jsch/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -3069,6 +3069,7 @@ private void applyConfig() throws JSchException {
checkConfig(config, "enable_pubkey_auth_query");
checkConfig(config, "try_additional_pubkey_algorithms");
checkConfig(config, "enable_auth_none");
checkConfig(config, "use_sftp_write_flush_workaround");

checkConfig(config, "cipher.c2s");
checkConfig(config, "cipher.s2c");
Expand Down