Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
tool
/
xxl-job
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 17b416ca
authored
Jun 11, 2020
by
xuxueli
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
通用HTTP任务Handler(httpJobHandler)优化:修复 "setDoOutput(true)" 导致任务请求GetMethod失效问题;
1 parent
16ba18ea
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
13 deletions
xxl-job-executor-samples/xxl-job-executor-sample-frameless/src/main/java/com/xuxueli/executor/sample/frameless/jobhandler/HttpJobHandler.java
xxl-job-executor-samples/xxl-job-executor-sample-jboot/src/main/java/com/xuxueli/executor/sample/jboot/jobhandler/HttpJobHandler.java
xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/HttpJobHandler.java
xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/HttpJobHandler.java
xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java
xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java
xxl-job-executor-samples/xxl-job-executor-sample-frameless/src/main/java/com/xuxueli/executor/sample/frameless/jobhandler/HttpJobHandler.java
View file @
17b416c
...
@@ -51,6 +51,7 @@ public class HttpJobHandler extends IJobHandler {
...
@@ -51,6 +51,7 @@ public class HttpJobHandler extends IJobHandler {
XxlJobLogger
.
log
(
"method["
+
method
+
"] invalid."
);
XxlJobLogger
.
log
(
"method["
+
method
+
"] invalid."
);
return
ReturnT
.
FAIL
;
return
ReturnT
.
FAIL
;
}
}
boolean
isPostMethod
=
method
.
equals
(
"POST"
);
// request
// request
HttpURLConnection
connection
=
null
;
HttpURLConnection
connection
=
null
;
...
@@ -62,7 +63,7 @@ public class HttpJobHandler extends IJobHandler {
...
@@ -62,7 +63,7 @@ public class HttpJobHandler extends IJobHandler {
// connection setting
// connection setting
connection
.
setRequestMethod
(
method
);
connection
.
setRequestMethod
(
method
);
connection
.
setDoOutput
(
true
);
connection
.
setDoOutput
(
isPostMethod
);
connection
.
setDoInput
(
true
);
connection
.
setDoInput
(
true
);
connection
.
setUseCaches
(
false
);
connection
.
setUseCaches
(
false
);
connection
.
setReadTimeout
(
5
*
1000
);
connection
.
setReadTimeout
(
5
*
1000
);
...
@@ -75,7 +76,7 @@ public class HttpJobHandler extends IJobHandler {
...
@@ -75,7 +76,7 @@ public class HttpJobHandler extends IJobHandler {
connection
.
connect
();
connection
.
connect
();
// data
// data
if
(
data
!=
null
&&
data
.
trim
().
length
()>
0
)
{
if
(
isPostMethod
&&
data
!=
null
&&
data
.
trim
().
length
()>
0
)
{
DataOutputStream
dataOutputStream
=
new
DataOutputStream
(
connection
.
getOutputStream
());
DataOutputStream
dataOutputStream
=
new
DataOutputStream
(
connection
.
getOutputStream
());
dataOutputStream
.
write
(
data
.
getBytes
(
"UTF-8"
));
dataOutputStream
.
write
(
data
.
getBytes
(
"UTF-8"
));
dataOutputStream
.
flush
();
dataOutputStream
.
flush
();
...
...
xxl-job-executor-samples/xxl-job-executor-sample-jboot/src/main/java/com/xuxueli/executor/sample/jboot/jobhandler/HttpJobHandler.java
View file @
17b416c
...
@@ -51,8 +51,9 @@ public class HttpJobHandler extends IJobHandler {
...
@@ -51,8 +51,9 @@ public class HttpJobHandler extends IJobHandler {
XxlJobLogger
.
log
(
"method["
+
method
+
"] invalid."
);
XxlJobLogger
.
log
(
"method["
+
method
+
"] invalid."
);
return
ReturnT
.
FAIL
;
return
ReturnT
.
FAIL
;
}
}
boolean
isPostMethod
=
method
.
equals
(
"POST"
);
// request
// request
HttpURLConnection
connection
=
null
;
HttpURLConnection
connection
=
null
;
BufferedReader
bufferedReader
=
null
;
BufferedReader
bufferedReader
=
null
;
try
{
try
{
...
@@ -62,7 +63,7 @@ public class HttpJobHandler extends IJobHandler {
...
@@ -62,7 +63,7 @@ public class HttpJobHandler extends IJobHandler {
// connection setting
// connection setting
connection
.
setRequestMethod
(
method
);
connection
.
setRequestMethod
(
method
);
connection
.
setDoOutput
(
true
);
connection
.
setDoOutput
(
isPostMethod
);
connection
.
setDoInput
(
true
);
connection
.
setDoInput
(
true
);
connection
.
setUseCaches
(
false
);
connection
.
setUseCaches
(
false
);
connection
.
setReadTimeout
(
5
*
1000
);
connection
.
setReadTimeout
(
5
*
1000
);
...
@@ -75,7 +76,7 @@ public class HttpJobHandler extends IJobHandler {
...
@@ -75,7 +76,7 @@ public class HttpJobHandler extends IJobHandler {
connection
.
connect
();
connection
.
connect
();
// data
// data
if
(
data
!=
null
&&
data
.
trim
().
length
()>
0
)
{
if
(
isPostMethod
&&
data
!=
null
&&
data
.
trim
().
length
()>
0
)
{
DataOutputStream
dataOutputStream
=
new
DataOutputStream
(
connection
.
getOutputStream
());
DataOutputStream
dataOutputStream
=
new
DataOutputStream
(
connection
.
getOutputStream
());
dataOutputStream
.
write
(
data
.
getBytes
(
"UTF-8"
));
dataOutputStream
.
write
(
data
.
getBytes
(
"UTF-8"
));
dataOutputStream
.
flush
();
dataOutputStream
.
flush
();
...
...
xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/HttpJobHandler.java
View file @
17b416c
...
@@ -51,6 +51,7 @@ public class HttpJobHandler extends IJobHandler {
...
@@ -51,6 +51,7 @@ public class HttpJobHandler extends IJobHandler {
XxlJobLogger
.
log
(
"method["
+
method
+
"] invalid."
);
XxlJobLogger
.
log
(
"method["
+
method
+
"] invalid."
);
return
ReturnT
.
FAIL
;
return
ReturnT
.
FAIL
;
}
}
boolean
isPostMethod
=
method
.
equals
(
"POST"
);
// request
// request
HttpURLConnection
connection
=
null
;
HttpURLConnection
connection
=
null
;
...
@@ -62,7 +63,7 @@ public class HttpJobHandler extends IJobHandler {
...
@@ -62,7 +63,7 @@ public class HttpJobHandler extends IJobHandler {
// connection setting
// connection setting
connection
.
setRequestMethod
(
method
);
connection
.
setRequestMethod
(
method
);
connection
.
setDoOutput
(
true
);
connection
.
setDoOutput
(
isPostMethod
);
connection
.
setDoInput
(
true
);
connection
.
setDoInput
(
true
);
connection
.
setUseCaches
(
false
);
connection
.
setUseCaches
(
false
);
connection
.
setReadTimeout
(
5
*
1000
);
connection
.
setReadTimeout
(
5
*
1000
);
...
@@ -75,7 +76,7 @@ public class HttpJobHandler extends IJobHandler {
...
@@ -75,7 +76,7 @@ public class HttpJobHandler extends IJobHandler {
connection
.
connect
();
connection
.
connect
();
// data
// data
if
(
data
!=
null
&&
data
.
trim
().
length
()>
0
)
{
if
(
isPostMethod
&&
data
!=
null
&&
data
.
trim
().
length
()>
0
)
{
DataOutputStream
dataOutputStream
=
new
DataOutputStream
(
connection
.
getOutputStream
());
DataOutputStream
dataOutputStream
=
new
DataOutputStream
(
connection
.
getOutputStream
());
dataOutputStream
.
write
(
data
.
getBytes
(
"UTF-8"
));
dataOutputStream
.
write
(
data
.
getBytes
(
"UTF-8"
));
dataOutputStream
.
flush
();
dataOutputStream
.
flush
();
...
...
xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/HttpJobHandler.java
View file @
17b416c
...
@@ -51,6 +51,7 @@ public class HttpJobHandler extends IJobHandler {
...
@@ -51,6 +51,7 @@ public class HttpJobHandler extends IJobHandler {
XxlJobLogger
.
log
(
"method["
+
method
+
"] invalid."
);
XxlJobLogger
.
log
(
"method["
+
method
+
"] invalid."
);
return
ReturnT
.
FAIL
;
return
ReturnT
.
FAIL
;
}
}
boolean
isPostMethod
=
method
.
equals
(
"POST"
);
// request
// request
HttpURLConnection
connection
=
null
;
HttpURLConnection
connection
=
null
;
...
@@ -62,7 +63,7 @@ public class HttpJobHandler extends IJobHandler {
...
@@ -62,7 +63,7 @@ public class HttpJobHandler extends IJobHandler {
// connection setting
// connection setting
connection
.
setRequestMethod
(
method
);
connection
.
setRequestMethod
(
method
);
connection
.
setDoOutput
(
true
);
connection
.
setDoOutput
(
isPostMethod
);
connection
.
setDoInput
(
true
);
connection
.
setDoInput
(
true
);
connection
.
setUseCaches
(
false
);
connection
.
setUseCaches
(
false
);
connection
.
setReadTimeout
(
5
*
1000
);
connection
.
setReadTimeout
(
5
*
1000
);
...
@@ -75,7 +76,7 @@ public class HttpJobHandler extends IJobHandler {
...
@@ -75,7 +76,7 @@ public class HttpJobHandler extends IJobHandler {
connection
.
connect
();
connection
.
connect
();
// data
// data
if
(
data
!=
null
&&
data
.
trim
().
length
()>
0
)
{
if
(
isPostMethod
&&
data
!=
null
&&
data
.
trim
().
length
()>
0
)
{
DataOutputStream
dataOutputStream
=
new
DataOutputStream
(
connection
.
getOutputStream
());
DataOutputStream
dataOutputStream
=
new
DataOutputStream
(
connection
.
getOutputStream
());
dataOutputStream
.
write
(
data
.
getBytes
(
"UTF-8"
));
dataOutputStream
.
write
(
data
.
getBytes
(
"UTF-8"
));
dataOutputStream
.
flush
();
dataOutputStream
.
flush
();
...
...
xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java
View file @
17b416c
...
@@ -151,6 +151,7 @@ public class SampleXxlJob {
...
@@ -151,6 +151,7 @@ public class SampleXxlJob {
XxlJobLogger
.
log
(
"method["
+
method
+
"] invalid."
);
XxlJobLogger
.
log
(
"method["
+
method
+
"] invalid."
);
return
ReturnT
.
FAIL
;
return
ReturnT
.
FAIL
;
}
}
boolean
isPostMethod
=
method
.
equals
(
"POST"
);
// request
// request
HttpURLConnection
connection
=
null
;
HttpURLConnection
connection
=
null
;
...
@@ -162,7 +163,7 @@ public class SampleXxlJob {
...
@@ -162,7 +163,7 @@ public class SampleXxlJob {
// connection setting
// connection setting
connection
.
setRequestMethod
(
method
);
connection
.
setRequestMethod
(
method
);
connection
.
setDoOutput
(
true
);
connection
.
setDoOutput
(
isPostMethod
);
connection
.
setDoInput
(
true
);
connection
.
setDoInput
(
true
);
connection
.
setUseCaches
(
false
);
connection
.
setUseCaches
(
false
);
connection
.
setReadTimeout
(
5
*
1000
);
connection
.
setReadTimeout
(
5
*
1000
);
...
@@ -175,7 +176,7 @@ public class SampleXxlJob {
...
@@ -175,7 +176,7 @@ public class SampleXxlJob {
connection
.
connect
();
connection
.
connect
();
// data
// data
if
(
data
!=
null
&&
data
.
trim
().
length
()>
0
)
{
if
(
isPostMethod
&&
data
!=
null
&&
data
.
trim
().
length
()>
0
)
{
DataOutputStream
dataOutputStream
=
new
DataOutputStream
(
connection
.
getOutputStream
());
DataOutputStream
dataOutputStream
=
new
DataOutputStream
(
connection
.
getOutputStream
());
dataOutputStream
.
write
(
data
.
getBytes
(
"UTF-8"
));
dataOutputStream
.
write
(
data
.
getBytes
(
"UTF-8"
));
dataOutputStream
.
flush
();
dataOutputStream
.
flush
();
...
...
xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java
View file @
17b416c
...
@@ -151,6 +151,7 @@ public class SampleXxlJob {
...
@@ -151,6 +151,7 @@ public class SampleXxlJob {
XxlJobLogger
.
log
(
"method["
+
method
+
"] invalid."
);
XxlJobLogger
.
log
(
"method["
+
method
+
"] invalid."
);
return
ReturnT
.
FAIL
;
return
ReturnT
.
FAIL
;
}
}
boolean
isPostMethod
=
method
.
equals
(
"POST"
);
// request
// request
HttpURLConnection
connection
=
null
;
HttpURLConnection
connection
=
null
;
...
@@ -162,7 +163,7 @@ public class SampleXxlJob {
...
@@ -162,7 +163,7 @@ public class SampleXxlJob {
// connection setting
// connection setting
connection
.
setRequestMethod
(
method
);
connection
.
setRequestMethod
(
method
);
connection
.
setDoOutput
(
true
);
connection
.
setDoOutput
(
isPostMethod
);
connection
.
setDoInput
(
true
);
connection
.
setDoInput
(
true
);
connection
.
setUseCaches
(
false
);
connection
.
setUseCaches
(
false
);
connection
.
setReadTimeout
(
5
*
1000
);
connection
.
setReadTimeout
(
5
*
1000
);
...
@@ -175,7 +176,7 @@ public class SampleXxlJob {
...
@@ -175,7 +176,7 @@ public class SampleXxlJob {
connection
.
connect
();
connection
.
connect
();
// data
// data
if
(
data
!=
null
&&
data
.
trim
().
length
()>
0
)
{
if
(
isPostMethod
&&
data
!=
null
&&
data
.
trim
().
length
()>
0
)
{
DataOutputStream
dataOutputStream
=
new
DataOutputStream
(
connection
.
getOutputStream
());
DataOutputStream
dataOutputStream
=
new
DataOutputStream
(
connection
.
getOutputStream
());
dataOutputStream
.
write
(
data
.
getBytes
(
"UTF-8"
));
dataOutputStream
.
write
(
data
.
getBytes
(
"UTF-8"
));
dataOutputStream
.
flush
();
dataOutputStream
.
flush
();
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment