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
4b2f3a4e
Unverified
Commit
4b2f3a4e
authored
Mar 04, 2020
by
Brian Krische
Committed by
GitHub
Mar 04, 2020
Browse files
Implement AutoCloseable to close the underlying client. (#520)
parent
75a66339
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/GitLabApi.java
View file @
4b2f3a4e
package
org.gitlab4j.api
;
package
org.gitlab4j.api
;
import
java.io.Closeable
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -23,7 +24,7 @@ import org.gitlab4j.api.utils.SecretString;
...
@@ -23,7 +24,7 @@ import org.gitlab4j.api.utils.SecretString;
* This class is provides a simplified interface to a GitLab API server, and divides the API up into
* This class is provides a simplified interface to a GitLab API server, and divides the API up into
* a separate API class for each concern.
* a separate API class for each concern.
*/
*/
public
class
GitLabApi
{
public
class
GitLabApi
implements
AutoCloseable
{
private
final
static
Logger
LOGGER
=
Logger
.
getLogger
(
GitLabApi
.
class
.
getName
());
private
final
static
Logger
LOGGER
=
Logger
.
getLogger
(
GitLabApi
.
class
.
getName
());
...
@@ -482,6 +483,17 @@ public class GitLabApi {
...
@@ -482,6 +483,17 @@ public class GitLabApi {
return
(
this
);
return
(
this
);
}
}
/**
* Close the underlying {@link javax.ws.rs.client.Client} and its associated resources.
*/
@Override
public
void
close
()
{
if
(
apiClient
!=
null
)
{
apiClient
.
close
();
}
}
/**
/**
* Enable the logging of the requests to and the responses from the GitLab server API
* Enable the logging of the requests to and the responses from the GitLab server API
* using the GitLab4J shared Logger instance and Level.FINE as the level.
* using the GitLab4J shared Logger instance and Level.FINE as the level.
...
...
src/main/java/org/gitlab4j/api/GitLabApiClient.java
View file @
4b2f3a4e
...
@@ -48,7 +48,7 @@ import org.glassfish.jersey.media.multipart.file.FileDataBodyPart;
...
@@ -48,7 +48,7 @@ import org.glassfish.jersey.media.multipart.file.FileDataBodyPart;
/**
/**
* This class utilizes the Jersey client package to communicate with a GitLab API endpoint.
* This class utilizes the Jersey client package to communicate with a GitLab API endpoint.
*/
*/
public
class
GitLabApiClient
{
public
class
GitLabApiClient
implements
AutoCloseable
{
protected
static
final
String
PRIVATE_TOKEN_HEADER
=
"PRIVATE-TOKEN"
;
protected
static
final
String
PRIVATE_TOKEN_HEADER
=
"PRIVATE-TOKEN"
;
protected
static
final
String
SUDO_HEADER
=
"Sudo"
;
protected
static
final
String
SUDO_HEADER
=
"Sudo"
;
...
@@ -243,6 +243,16 @@ public class GitLabApiClient {
...
@@ -243,6 +243,16 @@ public class GitLabApiClient {
clientConfig
.
register
(
MultiPartFeature
.
class
);
clientConfig
.
register
(
MultiPartFeature
.
class
);
}
}
/**
* Close the underlying {@link Client} and its associated resources.
*/
@Override
public
void
close
()
{
if
(
apiClient
!=
null
)
{
apiClient
.
close
();
}
}
/**
/**
* Enable the logging of the requests to and the responses from the GitLab server API.
* Enable the logging of the requests to and the responses from the GitLab server API.
*
*
...
...
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