Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
22bffd04
Commit
22bffd04
authored
May 13, 2019
by
Greg Messner
Browse files
Improved handling of exceptions.
parent
b0bf7ed7
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/systemhooks/SystemHookManager.java
View file @
22bffd04
...
@@ -147,9 +147,10 @@ public class SystemHookManager implements HookManager {
...
@@ -147,9 +147,10 @@ public class SystemHookManager implements HookManager {
}
}
// Unmarshal the tree to a concrete instance of a SystemHookEvent and fire the event to any listeners
// Unmarshal the tree to a concrete instance of a SystemHookEvent and fire the event to any listeners
SystemHookEvent
event
;
try
{
try
{
SystemHookEvent
event
=
jacksonJson
.
unmarshal
(
SystemHookEvent
.
class
,
tree
);
event
=
jacksonJson
.
unmarshal
(
SystemHookEvent
.
class
,
tree
);
if
(
LOGGER
.
isLoggable
(
Level
.
FINE
))
{
if
(
LOGGER
.
isLoggable
(
Level
.
FINE
))
{
LOGGER
.
fine
(
event
.
getEventName
()
+
"\n"
+
jacksonJson
.
marshal
(
event
)
+
"\n"
);
LOGGER
.
fine
(
event
.
getEventName
()
+
"\n"
+
jacksonJson
.
marshal
(
event
)
+
"\n"
);
}
}
...
@@ -157,12 +158,21 @@ public class SystemHookManager implements HookManager {
...
@@ -157,12 +158,21 @@ public class SystemHookManager implements HookManager {
StringBuffer
requestUrl
=
request
.
getRequestURL
();
StringBuffer
requestUrl
=
request
.
getRequestURL
();
event
.
setRequestUrl
(
requestUrl
!=
null
?
requestUrl
.
toString
()
:
null
);
event
.
setRequestUrl
(
requestUrl
!=
null
?
requestUrl
.
toString
()
:
null
);
event
.
setRequestQueryString
(
request
.
getQueryString
());
event
.
setRequestQueryString
(
request
.
getQueryString
());
}
catch
(
Exception
e
)
{
LOGGER
.
warning
(
String
.
format
(
"Error processing JSON data, exception=%s, error=%s"
,
e
.
getClass
().
getSimpleName
(),
e
.
getMessage
()));
throw
new
GitLabApiException
(
e
);
}
try
{
fireEvent
(
event
);
fireEvent
(
event
);
return
(
event
);
return
(
event
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOGGER
.
warning
(
"Error processing
JSON data
, exception=
"
+
LOGGER
.
warning
(
String
.
format
(
"Error processing
event
, exception=
%s, error=%s"
,
e
.
getClass
().
getSimpleName
()
+
", error="
+
e
.
getMessage
());
e
.
getClass
().
getSimpleName
()
,
e
.
getMessage
())
)
;
throw
new
GitLabApiException
(
e
);
throw
new
GitLabApiException
(
e
);
}
}
}
}
...
...
src/main/java/org/gitlab4j/api/webhook/WebHookManager.java
View file @
22bffd04
...
@@ -116,9 +116,9 @@ public class WebHookManager implements HookManager {
...
@@ -116,9 +116,9 @@ public class WebHookManager implements HookManager {
throw
new
GitLabApiException
(
message
);
throw
new
GitLabApiException
(
message
);
}
}
Event
event
;
try
{
try
{
Event
event
;
if
(
LOGGER
.
isLoggable
(
Level
.
FINE
))
{
if
(
LOGGER
.
isLoggable
(
Level
.
FINE
))
{
LOGGER
.
fine
(
HttpRequestUtils
.
getShortRequestDump
(
eventName
+
" webhook"
,
true
,
request
));
LOGGER
.
fine
(
HttpRequestUtils
.
getShortRequestDump
(
eventName
+
" webhook"
,
true
,
request
));
String
postData
=
HttpRequestUtils
.
getPostDataAsString
(
request
);
String
postData
=
HttpRequestUtils
.
getPostDataAsString
(
request
);
...
@@ -130,13 +130,22 @@ public class WebHookManager implements HookManager {
...
@@ -130,13 +130,22 @@ public class WebHookManager implements HookManager {
event
=
jacksonJson
.
unmarshal
(
Event
.
class
,
reader
);
event
=
jacksonJson
.
unmarshal
(
Event
.
class
,
reader
);
}
}
}
catch
(
Exception
e
)
{
LOGGER
.
warning
(
String
.
format
(
"Error processing JSON data, exception=%s, error=%s"
,
e
.
getClass
().
getSimpleName
(),
e
.
getMessage
()));
throw
new
GitLabApiException
(
e
);
}
try
{
event
.
setRequestUrl
(
request
.
getRequestURL
().
toString
());
event
.
setRequestUrl
(
request
.
getRequestURL
().
toString
());
event
.
setRequestQueryString
(
request
.
getQueryString
());
event
.
setRequestQueryString
(
request
.
getQueryString
());
fireEvent
(
event
);
fireEvent
(
event
);
return
(
event
);
return
(
event
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOGGER
.
warning
(
"Error parsing JSON data, exception="
+
e
.
getClass
().
getSimpleName
()
+
", error="
+
e
.
getMessage
());
LOGGER
.
warning
(
String
.
format
(
"Error processing event, exception=%s, error=%s"
,
e
.
getClass
().
getSimpleName
(),
e
.
getMessage
()));
throw
new
GitLabApiException
(
e
);
throw
new
GitLabApiException
(
e
);
}
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
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 comment