Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release #241

Merged
merged 2 commits into from
Apr 1, 2024
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog

## [Unreleased]
### Changed
- Mark `aspectjrt` dependency as `implementation`, by @HardNorth
- Move `CookieJar` object to static final field in ReportPortal class to use one instance for all HTTP clients, by @HardNorth

## [5.2.8]
### Added
Expand Down
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,23 @@ dependencies {
api ('com.epam.reportportal:commons-model:5.0.0') {
exclude module: 'jackson-databind'
}
api 'com.fasterxml.jackson.core:jackson-databind:2.12.7.1' // Access is needed by HTTP loggers to format JSON
api 'io.reactivex.rxjava2:rxjava:2.2.10'
api 'com.google.code.findbugs:jsr305:3.0.2'

api ("com.squareup.retrofit2:retrofit:${project.retrofit_version}") {
exclude module: 'okhttp'
}
api 'com.fasterxml.jackson.core:jackson-databind:2.12.7.1' // Access is needed by HTTP loggers to format JSON
implementation "com.squareup.okhttp3:okhttp:${project.okhttp_version}"
implementation "com.squareup.retrofit2:converter-scalars:${project.retrofit_version}"
implementation ("com.squareup.retrofit2:converter-jackson:${project.retrofit_version}") {
exclude module: 'jackson-databind'
}
implementation ("com.squareup.retrofit2:adapter-rxjava2:${project.retrofit_version}") {
exclude module: 'rxjava'
}
implementation "com.squareup.okhttp3:okhttp:${project.okhttp_version}"
implementation "com.squareup.okhttp3:logging-interceptor:${project.okhttp_version}"

api "org.aspectj:aspectjrt:${project.aspectj_version}"
implementation "org.aspectj:aspectjrt:${project.aspectj_version}"
implementation "org.aspectj:aspectjweaver:${project.aspectj_version}"

implementation 'org.slf4j:slf4j-api:2.0.7'
Expand Down
29 changes: 15 additions & 14 deletions src/main/java/com/epam/reportportal/service/ReportPortal.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@
public class ReportPortal {

private static final Logger LOGGER = LoggerFactory.getLogger(ReportPortal.class);
private static final CookieJar COOKIE_JAR = new CookieJar() {
private final Map<String, CopyOnWriteArrayList<Cookie>> STORAGE = new ConcurrentHashMap<>();

@Override
public void saveFromResponse(@Nonnull HttpUrl url, @Nonnull List<Cookie> cookies) {
STORAGE.computeIfAbsent(url.url().getHost(), u -> new CopyOnWriteArrayList<>()).addAll(cookies);
}

@Override
@Nonnull
public List<Cookie> loadForRequest(@Nonnull HttpUrl url) {
return STORAGE.computeIfAbsent(url.url().getHost(), u -> new CopyOnWriteArrayList<>());
}
};

private final ListenerParameters parameters;
private final LaunchIdLock launchIdLock;
Expand Down Expand Up @@ -556,20 +570,7 @@ protected OkHttpClient defaultClient(@Nonnull ListenerParameters parameters) {
ofNullable(parameters.getHttpReadTimeout()).ifPresent(builder::readTimeout);
ofNullable(parameters.getHttpWriteTimeout()).ifPresent(builder::writeTimeout);

builder.retryOnConnectionFailure(true).cookieJar(new CookieJar() {
private final Map<String, CopyOnWriteArrayList<Cookie>> STORAGE = new ConcurrentHashMap<>();

@Override
public void saveFromResponse(@Nonnull HttpUrl url, @Nonnull List<Cookie> cookies) {
STORAGE.computeIfAbsent(url.url().getHost(), u -> new CopyOnWriteArrayList<>()).addAll(cookies);
}

@Override
@Nonnull
public List<Cookie> loadForRequest(@Nonnull HttpUrl url) {
return STORAGE.computeIfAbsent(url.url().getHost(), u -> new CopyOnWriteArrayList<>());
}
});
builder.retryOnConnectionFailure(true).cookieJar(COOKIE_JAR);
return builder.build();
}

Expand Down