Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ build/
*.iml
out/
.vscode/
bin/

AGENTS.md
PROMPTS.md
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Changelog

## [Unreleased]
### Added
- `LockCloseable` class as a separate entity, by @HardNorth

## [5.4.4]
### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ rp.project=project-name

> **Note:** `rp.oauth.client.secret` and `rp.oauth.scope` are optional parameters.

> If mandatory parameters are missed client will log a warning and will be initialized in inactive state.
> If mandatory parameters are missed client will throw an [InternalReportPortalClientException](https://github.com/reportportal/client-java/blob/master/src/main/java/com/epam/reportportal/exception/InternalReportPortalClientException.java).

### Multi-process join parameters

Expand Down
2 changes: 1 addition & 1 deletion README_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ rp.project=project-name

> **Note:** `rp.oauth.client.secret` and `rp.oauth.scope` are optional parameters.

> If mandatory parameters are missed client will log a warning and will be initialized in inactive state.
> If mandatory parameters are missed client will throw an [InternalReportPortalClientException](https://github.com/reportportal/client-java/blob/master/src/main/java/com/epam/reportportal/exception/InternalReportPortalClientException.java).

### Multi-process join parameters

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.epam.reportportal.exception.InternalReportPortalClientException;
import com.epam.reportportal.listeners.ListenerParameters;
import com.epam.reportportal.utils.concurrency.LockCloseable;
import com.epam.reportportal.utils.http.ClientUtils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand All @@ -33,7 +34,6 @@
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import static java.util.Optional.ofNullable;
Expand All @@ -46,32 +46,6 @@
*/
public class OAuth2PasswordGrantAuthInterceptor implements Interceptor {

/**
* AutoCloseable wrapper for Lock that enables try-with-resources usage.
*/
private static class LockCloseable implements AutoCloseable {
private final Lock lock;

private LockCloseable(Lock lock) {
this.lock = lock;
}

/**
* Locks the underlying lock and returns this instance for use in try-with-resources.
*
* @return this LockCloseable instance
*/
public LockCloseable lock() {
lock.lock();
return this;
}

@Override
public void close() {
lock.unlock();
}
}

private static final Logger LOGGER = LoggerFactory.getLogger(OAuth2PasswordGrantAuthInterceptor.class);
private static final ObjectMapper MAPPER = new ObjectMapper();
private static final long TOKEN_EXPIRY_BUFFER_MILLIS = TimeUnit.MINUTES.toMillis(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.epam.reportportal.message.TypeAwareByteSource;
import com.epam.reportportal.service.launch.PrimaryLaunch;
import com.epam.reportportal.service.launch.SecondaryLaunch;
import com.epam.reportportal.utils.MultithreadingUtils;
import com.epam.reportportal.utils.concurrency.MultithreadingUtils;
import com.epam.reportportal.utils.files.Utils;
import com.epam.reportportal.utils.http.ClientUtils;
import com.epam.reportportal.utils.http.HttpRequestUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.epam.reportportal.service.statistics.item.StatisticsEvent;
import com.epam.reportportal.service.statistics.item.StatisticsItem;
import com.epam.reportportal.utils.ClientIdProvider;
import com.epam.reportportal.utils.MultithreadingUtils;
import com.epam.reportportal.utils.concurrency.MultithreadingUtils;
import com.epam.reportportal.utils.properties.ClientProperties;
import com.epam.reportportal.utils.properties.DefaultProperties;
import com.epam.reportportal.utils.properties.SystemAttributesExtractor;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/epam/reportportal/utils/ObjectUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.epam.reportportal.utils;

import com.epam.reportportal.exception.InternalReportPortalClientException;
import com.epam.reportportal.service.OAuth2PasswordGrantAuthInterceptor;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand All @@ -25,6 +26,7 @@
import jakarta.annotation.Nonnull;

import java.io.IOException;
import java.util.concurrent.locks.Lock;

import static com.epam.reportportal.utils.CommonConstants.TEN_MEGABYTES;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2025 EPAM Systems
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.epam.reportportal.utils.concurrency;

import java.util.concurrent.locks.Lock;

/**
* AutoCloseable wrapper for Lock that enables try-with-resources usage.
*/
public class LockCloseable implements AutoCloseable {
private final Lock lock;

public LockCloseable(Lock lock) {
this.lock = lock;
}

/**
* Locks the underlying lock and returns this instance for use in try-with-resources.
*
* @return this LockCloseable instance
*/
public LockCloseable lock() {
lock.lock();
return this;
}

@Override
public void close() {
lock.unlock();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
package com.epam.reportportal.utils;
/*
* Copyright 2025 EPAM Systems
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.epam.reportportal.utils.concurrency;

import com.epam.reportportal.listeners.ListenerParameters;
import jakarta.annotation.Nonnull;
Expand Down