Skip to content

Commit 150df7e

Browse files
authored
Merge pull request #431 from norrisjeremy/20231113
0.2.13 changes
2 parents c96ddcf + d702bda commit 150df7e

9 files changed

Lines changed: 41 additions & 10 deletions

File tree

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
uses: actions/setup-java@v3
3737
with:
3838
distribution: 'zulu'
39-
java-version: '17'
39+
java-version: '21'
4040
check-latest: true
4141
cache: 'maven'
4242

.github/workflows/coverity.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
uses: actions/setup-java@v3
1313
with:
1414
distribution: 'zulu'
15-
java-version: '17'
15+
java-version: '21'
1616
check-latest: true
1717
cache: 'maven'
1818
- uses: vapier/coverity-scan-action@v1

.github/workflows/javadoc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
uses: actions/setup-java@v3
1717
with:
1818
distribution: 'zulu'
19-
java-version: '17'
19+
java-version: '21'
2020
check-latest: true
2121
- name: Build Javadoc
22-
run: mvn -B -V javadoc:javadoc --file pom.xml
22+
run: ./mvnw -B -V -e javadoc:javadoc
2323
- name: Deploy 🚀
2424
uses: JamesIves/github-pages-deploy-action@v4
2525
with:

.github/workflows/maven.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
strategy:
1919
matrix:
20-
java: ['8', '11', '17']
20+
java: ['8', '11', '17', '21']
2121
steps:
2222
- uses: actions/checkout@v4
2323
- name: Cache local Maven repository
@@ -31,10 +31,10 @@ jobs:
3131
uses: actions/setup-java@v3
3232
with:
3333
distribution: 'zulu'
34-
java-version: '17'
34+
java-version: '21'
3535
check-latest: true
3636
- name: Build with Maven
37-
run: mvn -B -V -DskipTests=true package --file pom.xml
37+
run: ./mvnw -B -V -e -DskipTests=true package
3838
- uses: actions/upload-artifact@v3
3939
with:
4040
name: java-${{ matrix.java }}-jars
@@ -49,7 +49,7 @@ jobs:
4949
java-version: ${{ matrix.java }}
5050
check-latest: true
5151
- name: Test with Maven
52-
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
52+
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
5353
- uses: actions/upload-artifact@v3
5454
with:
5555
name: java-${{ matrix.java }}-testresults

.mvn/wrapper/maven-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip
17+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
1818
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar

src/main/java/com/jcraft/jsch/Channel.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ static Channel getChannel(String type, Session session) {
6767
ret = new ChannelForwardedTCPIP();
6868
}
6969
if (type.equals("sftp")) {
70-
ret = new ChannelSftp();
70+
ChannelSftp sftp = new ChannelSftp();
71+
boolean useWriteFlushWorkaround =
72+
session.getConfig("use_sftp_write_flush_workaround").equals("yes");
73+
sftp.setUseWriteFlushWorkaround(useWriteFlushWorkaround);
74+
ret = sftp;
7175
}
7276
if (type.equals("subsystem")) {
7377
ret = new ChannelSubsystem();
@@ -204,6 +208,11 @@ public void setExtOutputStream(OutputStream out, boolean dontclose) {
204208
}
205209

206210
public InputStream getInputStream() throws IOException {
211+
Session _session = this.session;
212+
if (_session != null && isConnected() && _session.getLogger().isEnabled(Logger.WARN)) {
213+
_session.getLogger().log(Logger.WARN, "getInputStream() should be called before connect()");
214+
}
215+
207216
int max_input_buffer_size = 32 * 1024;
208217
try {
209218
max_input_buffer_size = Integer.parseInt(getSession().getConfig("max_input_buffer_size"));
@@ -217,6 +226,12 @@ public InputStream getInputStream() throws IOException {
217226
}
218227

219228
public InputStream getExtInputStream() throws IOException {
229+
Session _session = this.session;
230+
if (_session != null && isConnected() && _session.getLogger().isEnabled(Logger.WARN)) {
231+
_session.getLogger().log(Logger.WARN,
232+
"getExtInputStream() should be called before connect()");
233+
}
234+
220235
int max_input_buffer_size = 32 * 1024;
221236
try {
222237
max_input_buffer_size = Integer.parseInt(getSession().getConfig("max_input_buffer_size"));

src/main/java/com/jcraft/jsch/ChannelSftp.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ public class ChannelSftp extends ChannelSession {
157157
private Charset fEncoding = StandardCharsets.UTF_8;
158158
private boolean fEncoding_is_utf8 = true;
159159

160+
private boolean useWriteFlushWorkaround = true;
161+
160162
private RequestQueue rq = new RequestQueue(16);
161163

162164
/**
@@ -181,6 +183,14 @@ public int getBulkRequests() {
181183
return rq.size();
182184
}
183185

186+
public void setUseWriteFlushWorkaround(boolean useWriteFlushWorkaround) {
187+
this.useWriteFlushWorkaround = useWriteFlushWorkaround;
188+
}
189+
190+
public boolean getUseWriteFlushWorkaround() {
191+
return useWriteFlushWorkaround;
192+
}
193+
184194
public ChannelSftp() {
185195
super();
186196
lwsize_max = LOCAL_WINDOW_SIZE_MAX;
@@ -754,6 +764,9 @@ public void write(byte[] d, int s, int len) throws IOException {
754764
try {
755765
int _len = len;
756766
while (_len > 0) {
767+
if (useWriteFlushWorkaround && rwsize < 21 + handle.length + _len + 4) {
768+
flush();
769+
}
757770
int sent = sendWRITE(handle, _offset[0], d, s, _len);
758771
writecount++;
759772
_offset[0] += sent;

src/main/java/com/jcraft/jsch/JSch.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ public class JSch {
228228
config.put("try_additional_pubkey_algorithms",
229229
Util.getSystemProperty("jsch.try_additional_pubkey_algorithms", "yes"));
230230
config.put("enable_auth_none", Util.getSystemProperty("jsch.enable_auth_none", "yes"));
231+
config.put("use_sftp_write_flush_workaround",
232+
Util.getSystemProperty("jsch.use_sftp_write_flush_workaround", "yes"));
231233

232234
config.put("CheckCiphers",
233235
Util.getSystemProperty("jsch.check_ciphers", "chacha20-poly1305@openssh.com"));

src/main/java/com/jcraft/jsch/Session.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3069,6 +3069,7 @@ private void applyConfig() throws JSchException {
30693069
checkConfig(config, "enable_pubkey_auth_query");
30703070
checkConfig(config, "try_additional_pubkey_algorithms");
30713071
checkConfig(config, "enable_auth_none");
3072+
checkConfig(config, "use_sftp_write_flush_workaround");
30723073

30733074
checkConfig(config, "cipher.c2s");
30743075
checkConfig(config, "cipher.s2c");

0 commit comments

Comments
 (0)