Skip to content

Commit c233c3f

Browse files
author
Kalin Kostashki
committed
Merge branch 'master' into feature/importing-policies
2 parents e2d700a + 7310229 commit c233c3f

24 files changed

+456
-125
lines changed

CODE_OF_CONDUCT.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Community Code of Conduct
2+
3+
**Version 1.2
4+
August 19, 2020**
5+
6+
## Our Pledge
7+
8+
In the interest of fostering an open and welcoming environment, we as community members, contributors, committers, and project leaders pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
9+
10+
## Our Standards
11+
12+
Examples of behavior that contributes to creating a positive environment include:
13+
14+
* Using welcoming and inclusive language
15+
* Being respectful of differing viewpoints and experiences
16+
* Gracefully accepting constructive criticism
17+
* Focusing on what is best for the community
18+
* Showing empathy towards other community members
19+
20+
Examples of unacceptable behavior by participants include:
21+
22+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
23+
* Trolling, insulting/derogatory comments, and personal or political attacks
24+
* Public or private harassment
25+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
26+
* Other conduct which could reasonably be considered inappropriate in a professional setting
27+
28+
## Our Responsibilities
29+
30+
With the support of the Eclipse Foundation staff (the “Staff”), project committers and leaders are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
31+
32+
Project committers and leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
33+
34+
## Scope
35+
36+
This Code of Conduct applies within all project spaces, and it also applies when an individual is representing the Eclipse Foundation project or its community in public spaces. Examples of representing a project or community include posting via an official social media account, or acting as a project representative at an online or offline event. Representation of a project may be further defined and clarified by project committers, leaders, or the EMO.
37+
38+
## Enforcement
39+
40+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the Staff at codeofconduct@eclipse.org. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The Staff is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
41+
42+
Project committers or leaders who do not follow the Code of Conduct in good faith may face temporary or permanent repercussions as determined by the Staff.
43+
44+
## Attribution
45+
46+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org) , version 1.4, available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct.html](https://www.contributor-covenant.org/version/1/4/code-of-conduct/)

SECURITY.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
These versions of Eclipse Ditto Clients are currently being supported with security updates.
6+
7+
| Version | Supported |
8+
|---------| ------------------ |
9+
| 3.0.x | :white_check_mark: |
10+
| 2.4.x | :white_check_mark: |
11+
| < 2.4.0 | :x: |
12+
13+
## Reporting a Vulnerability
14+
15+
Please report a found vulnerability here: [https://www.eclipse.org/security/](https://www.eclipse.org/security/)

java/pom.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@
239239
<!-- globally set version for checking binary compatibility against -->
240240
<!-- whoever changes this to ${revision} or ${project.version} is responsible for API breakage caused by this! -->
241241
<!-- in other words: never do that here! exclude the 'breakages' locally in the japicmp maven plugin if you intentionally break something -->
242-
<binary-compatibility-check.version>2.4.0</binary-compatibility-check.version>
242+
<binary-compatibility-check.version>3.0.0</binary-compatibility-check.version>
243243
<!-- skip until first release: -->
244244
<binary-compatibility-check.skip>false</binary-compatibility-check.skip>
245245

@@ -452,8 +452,6 @@
452452
<exclude>org.eclipse.ditto.client.twin.internal</exclude>
453453
<!-- this builder is an internal implementation of a builder interface and should not be handled as API: -->
454454
<exclude>org.eclipse.ditto.client.configuration.ClientCredentialsAuthenticationConfiguration$ClientCredentialsAuthenticationConfigurationBuilder</exclude>
455-
<exclude>org.eclipse.ditto.client.streaming.ThingSearchPublisher#of(org.eclipse.ditto.base.model.signals.Signal,org.eclipse.ditto.protocol.adapter.ProtocolAdapter,org.eclipse.ditto.client.messaging.MessagingProvider)</exclude>
456-
<exclude>org.eclipse.ditto.client.live.commands.query.RetrieveThingsLiveCommand</exclude>
457455
</excludes>
458456
</parameter>
459457
</configuration>

java/src/main/java/org/eclipse/ditto/client/DittoClient.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ public interface DittoClient {
5252
* Directly sends a Ditto Protocol {@link Adaptable} message to the established Ditto backend connection.
5353
*
5454
* @param dittoProtocolAdaptable the adaptable to send
55-
* @return a CompletionStage containing the correlated response to the sent {@code dittoProtocolAdaptable}
55+
* @return a CompletionStage containing the correlated response to the sent {@code dittoProtocolAdaptable} or
56+
* which failed with a {@link org.eclipse.ditto.client.management.ClientReconnectingException} if the client is
57+
* in a reconnecting state.
5658
* @throws IllegalStateException when no twin/live connection was configured for this client
5759
*/
5860
CompletionStage<Adaptable> sendDittoProtocol(Adaptable dittoProtocolAdaptable);

java/src/main/java/org/eclipse/ditto/client/configuration/MessagingConfiguration.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ interface Builder {
182182
* Register a consumer of errors which occur during opening the connection initially and on reconnects.
183183
*
184184
* @param handler the handler that will be called with the cause of the connection error.
185+
* @return this builder.
185186
* @since 1.2.0
186187
*/
187188
Builder connectionErrorHandler(@Nullable Consumer<Throwable> handler);
@@ -190,6 +191,7 @@ interface Builder {
190191
* Register a contextListener which is notified whenever the connection is disconnected.
191192
*
192193
* @param contextListener the handler that will be called with details about the disconnection.
194+
* @return this builder.
193195
* @since 2.1.0
194196
*/
195197
Builder disconnectedListener(@Nullable Consumer<DisconnectedContext> contextListener);

java/src/main/java/org/eclipse/ditto/client/internal/AbstractHandle.java

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.time.Duration;
1919
import java.util.Map;
2020
import java.util.Optional;
21+
import java.util.concurrent.CompletableFuture;
2122
import java.util.concurrent.CompletionStage;
2223
import java.util.function.Function;
2324
import java.util.function.Predicate;
@@ -40,6 +41,7 @@
4041
import org.eclipse.ditto.client.ack.internal.AcknowledgementRequestsValidator;
4142
import org.eclipse.ditto.client.internal.bus.Classification;
4243
import org.eclipse.ditto.client.management.AcknowledgementsFailedException;
44+
import org.eclipse.ditto.client.management.ClientReconnectingException;
4345
import org.eclipse.ditto.client.messaging.MessagingProvider;
4446
import org.eclipse.ditto.json.JsonField;
4547
import org.eclipse.ditto.json.JsonObject;
@@ -138,6 +140,8 @@ protected Signal signalFromAdaptable(final Adaptable adaptable) {
138140
* @param <R> type of the result.
139141
* @return future of the result if the expected response arrives or a failed future on error.
140142
* Type is {@code CompletionStage} to signify that the future will complete or fail without caller intervention.
143+
* If the client is reconnecting while this method is called the future fails with a
144+
* {@link ClientReconnectingException}.
141145
*/
142146
protected <T extends PolicyCommand<T>, S extends PolicyCommandResponse<?>, R> CompletionStage<R> askPolicyCommand(
143147
final T command,
@@ -159,11 +163,14 @@ protected <T extends PolicyCommand<T>, S extends PolicyCommandResponse<?>, R> Co
159163
* @param <R> type of the result.
160164
* @return future of the result if the expected response arrives or a failed future on error.
161165
* Type is {@code CompletionStage} to signify that the future will complete or fail without caller intervention.
166+
* If the client is reconnecting while this method is called the future fails with a
167+
* {@link ClientReconnectingException}.
162168
*/
163169
protected <T extends ThingCommand<T>, S extends CommandResponse<?>, R> CompletionStage<R> askThingCommand(
164170
final T command,
165171
final Class<S> expectedResponse,
166172
final Function<S, R> onSuccess) {
173+
167174
final ThingCommand<?> commandWithChannel = validateAckRequests(setChannel(command, channel));
168175
return sendSignalAndExpectResponse(commandWithChannel, expectedResponse, onSuccess, ErrorResponse.class,
169176
ErrorResponse::getDittoRuntimeException);
@@ -180,33 +187,42 @@ protected <T extends ThingCommand<T>, S extends CommandResponse<?>, R> Completio
180187
* @param <S> type of the expected success response.
181188
* @param <E> type of the expected error response.
182189
* @param <R> type of the result.
183-
* @return future of the result.
190+
* @return future of the result. The future can be exceptional with a {@link ClientReconnectingException} if the
191+
* client is reconnecting while this method is called.
184192
*/
185193
protected <S, E, R> CompletionStage<R> sendSignalAndExpectResponse(final Signal<?> signal,
186194
final Class<S> expectedResponseClass,
187195
final Function<S, R> onSuccess,
188196
final Class<E> expectedErrorResponseClass,
189197
final Function<E, ? extends RuntimeException> onError) {
190198

191-
final CompletionStage<Adaptable> responseFuture = messagingProvider.getAdaptableBus()
192-
.subscribeOnceForAdaptable(Classification.forCorrelationId(signal), getTimeout());
193-
194-
messagingProvider.emit(signalToJsonString(signal));
195-
return responseFuture.thenApply(responseAdaptable -> {
196-
final Signal<?> response = signalFromAdaptable(responseAdaptable);
197-
if (expectedErrorResponseClass.isInstance(response)) {
198-
// extracted runtime exception will be wrapped in CompletionException.
199-
throw onError.apply(expectedErrorResponseClass.cast(response));
200-
} else if (response instanceof Acknowledgements) {
201-
final CommandResponse<?> commandResponse =
202-
extractCommandResponseFromAcknowledgements(signal, (Acknowledgements) response);
203-
return onSuccess.apply(expectedResponseClass.cast(commandResponse));
204-
} else if (expectedResponseClass.isInstance(response)) {
205-
return onSuccess.apply(expectedResponseClass.cast(response));
206-
} else {
207-
throw new ClassCastException("Expect " + expectedResponseClass.getSimpleName() + ", got: " + response);
208-
}
209-
});
199+
try {
200+
final CompletionStage<Adaptable> responseFuture = messagingProvider.getAdaptableBus()
201+
.subscribeOnceForAdaptable(Classification.forCorrelationId(signal), getTimeout());
202+
203+
messagingProvider.emit(signalToJsonString(signal));
204+
return responseFuture.thenApply(responseAdaptable -> {
205+
final Signal<?> response = signalFromAdaptable(responseAdaptable);
206+
if (expectedErrorResponseClass.isInstance(response)) {
207+
// extracted runtime exception will be wrapped in CompletionException.
208+
throw onError.apply(expectedErrorResponseClass.cast(response));
209+
} else if (response instanceof Acknowledgements) {
210+
final CommandResponse<?> commandResponse =
211+
extractCommandResponseFromAcknowledgements(signal, (Acknowledgements) response);
212+
return onSuccess.apply(expectedResponseClass.cast(commandResponse));
213+
} else if (expectedResponseClass.isInstance(response)) {
214+
return onSuccess.apply(expectedResponseClass.cast(response));
215+
} else {
216+
throw new ClassCastException(
217+
"Expect " + expectedResponseClass.getSimpleName() + ", got: " + response);
218+
}
219+
});
220+
} catch (final ClientReconnectingException cre) {
221+
return CompletableFuture.supplyAsync(() -> {
222+
throw cre;
223+
});
224+
}
225+
210226
}
211227

212228
/**

java/src/main/java/org/eclipse/ditto/client/internal/CommonManagementImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ public CompletionStage<Void> startConsumption(final Option<?>... consumptionOpti
163163
* Starts the consumption of twin events / messages / live events and commands.
164164
*
165165
* @param consumptionConfig the configuration Map to apply for the consumption.
166-
* @return a CompletionStage that terminates when the start operation was successful.
166+
* @return a CompletionStage that terminates when the start operation was successful or fails if the client is in
167+
* a reconnecting state
167168
*/
168169
protected abstract CompletionStage<Void> doStartConsumption(Map<String, String> consumptionConfig);
169170

@@ -648,6 +649,7 @@ public void registerForThingChanges(final String registrationId, final Consumer<
648649
* @param futureToCompleteOrFailAfterAck the future to complete or fail after receiving the expected acknowledgement
649650
* or not.
650651
* @return the subscription ID.
652+
* @throws org.eclipse.ditto.client.management.ClientReconnectingException if the client client is reconnecting.
651653
*/
652654
protected AdaptableBus.SubscriptionId subscribe(
653655
@Nullable final AdaptableBus.SubscriptionId previousSubscriptionId,
@@ -730,6 +732,7 @@ private static String appendCorrelationIdParameter(final String protocolCommand,
730732
* @param protocolCommandAck the expected acknowledgement.
731733
* @param futureToCompleteOrFailAfterAck the future to complete or fail after receiving the expected acknowledgement
732734
* or not.
735+
* @throws org.eclipse.ditto.client.management.ClientReconnectingException if the client client is reconnecting.
733736
*/
734737
protected void unsubscribe(@Nullable final AdaptableBus.SubscriptionId subscriptionId,
735738
final String protocolCommand,

java/src/main/java/org/eclipse/ditto/client/internal/DefaultDittoClient.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ private static PoliciesImpl configurePolicyClient(final MessagingProvider messag
234234
final String busName = TopicPath.Channel.NONE.getName();
235235
final PointerBus bus = BusFactory.createPointerBus(busName, messagingProvider.getExecutorService());
236236
init(bus, messagingProvider);
237-
final MessagingConfiguration messagingConfiguration = messagingProvider.getMessagingConfiguration();
238237
final OutgoingMessageFactory messageFactory = getOutgoingMessageFactoryForPolicies(messagingProvider);
239238
return PoliciesImpl.newInstance(messagingProvider, messageFactory, bus);
240239
}

java/src/main/java/org/eclipse/ditto/client/live/LiveCommandProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public interface LiveCommandProcessor {
4141
* Publish a signal.
4242
*
4343
* @param signal the signal to publish.
44+
* @throws org.eclipse.ditto.client.management.ClientReconnectingException if the client is in a reconnecting state.
4445
*/
4546
void publishLiveSignal(Signal<?> signal);
4647

java/src/main/java/org/eclipse/ditto/client/live/commands/LiveCommandHandler.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public interface LiveCommandHandler<L extends LiveCommand<L, B>, B extends LiveC
3434
* @param type the type of live commands. MUST be an interface satisfying the recursive type bound.
3535
* @param commandHandler constructor of any response or event to publish.
3636
* @param <L> type of live commands.
37+
* @param <B> type of live command answers.
3738
* @return the live command handler.
3839
*/
3940
static <L extends LiveCommand<L, B>, B extends LiveCommandAnswerBuilder> LiveCommandHandler<L, B> of(
@@ -49,6 +50,7 @@ static <L extends LiveCommand<L, B>, B extends LiveCommandAnswerBuilder> LiveCom
4950
* @param type the type of live commands. MUST be an interface satisfying the recursive type bound.
5051
* @param commandHandler constructor of any response or event to publish and sender of any acknowledgements.
5152
* @param <L> type of live commands.
53+
* @param <B> type of live command answers.
5254
* @return the live command handler.
5355
*/
5456
static <L extends LiveCommand<L, B>, B extends LiveCommandAnswerBuilder> LiveCommandHandler<L, B> withAcks(
@@ -77,6 +79,7 @@ static <L extends LiveCommand<L, B>, B extends LiveCommandAnswerBuilder> LiveCom
7779
* To be called after runtime type check of the live command.
7880
*
7981
* @param liveCommand the live command.
82+
* @param signalPublisher the signal publisher.
8083
* @return the result of calling the command handler on the command.
8184
*/
8285
default LiveCommandAnswerBuilder.BuildStep castAndApply(final LiveCommand<?, ?> liveCommand,

java/src/main/java/org/eclipse/ditto/client/live/events/EventEmitter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public interface EventEmitter<F extends EventFactory> {
3030
*
3131
* @param eventFunction Function providing a EventFactory and requiring a Event as result.
3232
* @throws NullPointerException if {@code eventFunction} is {@code null}.
33+
* @throws org.eclipse.ditto.client.management.ClientReconnectingException if the client is reconnecting.
3334
*/
3435
void emitEvent(Function<F, Event<?>> eventFunction);
3536

0 commit comments

Comments
 (0)