profile
viewpoint

yonadev/yona-server 7

Yona Server

Bert-R/quartz-repro 1

Quartz example triggering one job twice

Bert-R/b3-propagation 0

Repository that describes and sometimes implements B3 propagation

Bert-R/citus_docs 0

Citus Documentation

Bert-R/eventuate-client-java 0

Eventuate Java client

Bert-R/fhir 0

FHIR Protocol Buffers

Bert-R/FhirPathTester 0

Simple WPF HL7 Fluentpath Tester tool

Bert-R/ghprb-plugin 0

github pull requests builder plugin for Jenkins

Bert-R/gradle-docker 0

A Gradle plugin to build Docker images from the build script.

Bert-R/gs-accessing-data-jpa 0

Accessing Data with JPA :: Learn how to work with JPA data persistence using Spring Data JPA.

PR opened yonadev/yona-server

YD-680 Include duration in raw activity report

Instead of having to process the result in Excel, the data can now be interpreted immediately.

+26 -5

0 comment

2 changed files

pr created time in 2 days

create barnchyonadev/yona-server

branch : yd-680-duration-in-raw-report

created branch time in 2 days

push eventyonadev/yona-server

Bert Roos

commit sha 4cdf1a7070fc6b614c88c809efba28d939b07b28

Removed com.sec.android.app.sbrowser This is the Samsung browser, not a communication app

view details

push time in 2 days

PR opened yonadev/yona-server

YD-679 Return 400 on MultipartException

Added MultipartException to the list of exceptions that cause a 400 status to be returned.

+2 -1

0 comment

1 changed file

pr created time in 4 days

create barnchyonadev/yona-server

branch : yd-679-500-on-multipart-ex

created branch time in 4 days

push eventyonadev/yona-server

Bert Roos

commit sha cdb252fef1762c4bbb14dadd72c1e5c4ee69e6e6

YD-665 Be explicit about availability of user anonymized Instead of 'get' on the optional userAnomymizedDto, we now use 'orElseThrow' with a clear message: Should have user anonymized when buddy relationship is established

view details

push time in 4 days

delete branch yonadev/yona-server

delete branch : yd-664-no-firebase-for-system-message

delete time in 4 days

delete branch yonadev/yona-server

delete branch : yd-662-encrypt-creation-time

delete time in 4 days

delete branch yonadev/yona-server

delete branch : yd-668-check-num-device-request

delete time in 4 days

delete branch yonadev/yona-server

delete branch : yd-674-sms-error-500

delete time in 4 days

delete branch yonadev/yona-server

delete branch : yd-669-pass-app-info

delete time in 4 days

delete branch yonadev/yona-server

delete branch : yd-676-clear-firebase-id

delete time in 4 days

delete branch yonadev/yona-server

delete branch : yd-673-mark-alerts

delete time in 4 days

delete branch yonadev/yona-server

delete branch : yd-675-details-prev-link

delete time in 4 days

delete branch yonadev/yona-server

delete branch : yd-677-multithreading-issue

delete time in 4 days

delete branch yonadev/yona-server

delete branch : yd-659-spring-boot-221

delete time in 4 days

create barnchyonadev/yona-server

branch : yd-665-improve-entity-loading

created branch time in 5 days

push eventyonadev/yona-server

Bert Roos

commit sha 20f0756953b8a1f8fbca80f232e937f2fc259494

YD-678 Optimized code based on SonarQube comment

view details

push time in 6 days

Pull request review commentyonadev/yona-server

YD-678 Improve Firebase implementation

 private long getMessageId(nu.yona.server.messaging.entities.Message message) 		return Optional.ofNullable(lastMessageByRegistrationToken.remove(registrationToken)); 	} -	private void sendMessage(String registrationToken, Message firebaseMessage)+	private void sendMessage(String registrationToken, UUID deviceAnonymizedId, Message firebaseMessage)

IMHO, the method readability would decrease if we would further break down this method.

Bert-R

comment created time in 6 days

push eventyonadev/yona-server

Bert Roos

commit sha 0a5431328a350ca4425312338162bd6349c3e9ed

YD-678 Removed excess log statement The log statement in saveFirebaseInstanceIdIfUpdated was added for debugging purposes. Removed it now.

view details

push time in 6 days

push eventyonadev/yona-server

Bert Roos

commit sha 57275fd9ba355d2cdd4fac90eb76fae0744fc74f

YD-678 Some cleanup

view details

push time in 7 days

PR opened yonadev/yona-server

YD-678 Improve Firebase implementation
  • Handle unregistered devices as part of the exception handling rather than in the completion handler. This gives cleaner failure scenarios.
  • Remove excess log statement that reported successful send
  • Created a unit test that verifies the FirebaseMessaging failure behavior

Along with this:

  • Updated TestController to use the much simpler entity model approach introduced with Spring HATEOAS 1.0
+277 -107

0 comment

5 changed files

pr created time in 7 days

create barnchyonadev/yona-server

branch : yd-678-polish-firebase

created branch time in 7 days

push eventyonadev/yona-server

Bert Roos

commit sha 8dce1dd08bffb6ba85055429b84cd3a631464af3

YD-659 Upgrade to Spring Boot 2.2.2 (#579) * YD-659 Ran Spring Hateoas migration script And made some manual changes. Many other changes are needed to get to Spring Hateaos 1.0.1 * YD-659 Use SimpleRepresentationModelAssembler ControllerBase now requires the interface RepresentationModelAssembler rather than the implementation class RepresentationModelAssemblerSupport. * YD-659 Everything compiles again Using a snapshot build of Spring Hateoas 1.1.0.M1 * YD-659 Fixed the unit tests We now use the Mockito version that comes with the Spring Boot version. Upgraded the equalsverifier to see whether it fixed our issue (it didn't). Then fixed the GoalDtoTest and removed a deprecation warning from DeviceServiceTest.java * YD-659 Made the integration tests work again Along with this standardized naming and type for link relations. They are all defined as LinkRelation XXX_REL. The message handlers need the name as well (for a switch statement). In that case, the string is defined as XXX_REL_NAME. * YD-659 Removed workaround for Spring Hateoas issue Issue spring-projects/spring-hateoas#703 is resolved in 1.1.0.M1, so removed the workaround. To verify this, the test password now includes a character that needs to be encoded, and the integration test verifies that this encoding is done properly. It is not strictly necessary to do this, as we nowadays only generate temp passwords that do not need encoding. However, the test was extended as the web service layer should not depend on the password strategy. * YD-659 Switched to Spring Hateoas 1.0.2 This release includes spring-projects/spring-hateoas#1126 and spring-projects/spring-hateoas#1130, so no need to wait for 1.1.0. * YD-659 Upgrade to Spring Boot 2.2.2 This includes Spring Hateoas 1.0.2 * YD-659 Removed direct spring-hateoas dependency It comes along with the starter already and the version number was wrong. * YD-659 Addressed SonarQube feedback * Used a method reference instead of a call * Removed unused import * YD-659 Upgraded to Spring Boot 2.2.3 This caused an issue that is resolved in Gradle 6.1, so upgraded to that. That however requires a newer version of the Gradle Docker plugin, so upgraded that to the latest version (6.1.2) * YD-659 Addressed review comments * Corrected comment in SecurityProperties (was accidentally updated by Spring HATEOAS upgrade script) * Corrected comment in CreateUserOnBuddyRequestTest.Hacking attempt: Try to get a user created on buddy request with normal Yona password header() * Replaced ActivityControllerBase.PREV_REL and ActivityControllerBase.NEXT_REL with IanaLinkRelations.PREV and IanaLinkRelations.NEXT respectively. * Replaced JsonRootLinkRelationProvider.EDIT_REL with IanaLinkRelations.EDIT * YD-659 Upgraded to Spring Boot 2.2.4 The issue that triggered the upgrade to Gradle 6.1 (spring-projects/spring-boot#19783) is resolved in this version, so strictly speaking, we can stick with the previous version of Gradle (and the Docker plug-in), but everything works, so let's move along.

view details

push time in 7 days

PR merged yonadev/yona-server

YD-659 Upgrade to Spring Boot 2.2.2

This includes Spring Hateoas 1.0.2, which implies a significant API change since the 0.25.1 version we were on.

We also could revert the fix for the double percent encoding, as that's now solved in Spring Hateoas.

+715 -654

1 comment

58 changed files

Bert-R

pr closed time in 7 days

push eventyonadev/yona-server

Bert Roos

commit sha 6cd98ad12f4b73f5d965817fdb1bc2ec5b3c0096

YD-673 Mark fatal issues with ALERT (#581) This is done for internal server errors occurring in HTTP requests and for asynchronous processes (Quartz jobs, batch jobs and async tasks (CompletableFuture.runAsync). Along with this: * Renamed nu.yona.server.rest.Constants into RestConstants, to prevent clashes in places where both are needed * The PASSWORD_HEADER constant was mostly statically imported. Did this now everywhere.

view details

Bert Roos

commit sha 97587c3c8e6578b50ef88c64b45391ce5dae5d00

Extra logging to track down Firebase issue

view details

Bert Roos

commit sha 9483cc0f853920c0455e459eaf58a995a4a808ea

YD-674 SmsException results in INTERNAL_SERVER_ERROR (#582)

view details

Bert Roos

commit sha 937ca1b7b6a29b09513f198981805bd1565ac302

YD-669 Init thread context on completion logging

view details

Bert Roos

commit sha f78c5776f5827b72bcaa0108a870c14616658f93

Merge branch 'master' of https://github.com/yonadev/yona-server

view details

Bert Roos

commit sha d67bc38cedd87141446830c9e55e453c43a5abd6

YD-675 Corrected prev links on day/week details (#583) * YD-675 Corrected prev links on day/week details * YD-675 Navigation link assessment is a separate test * YD-675 Processed review comment Added unit test for IntervalActivity.hasPrevious * YD-675 Cover mandatory goal creation date scenario

view details

Bert Roos

commit sha 154d8f134fa2bb71586d63be1c634fcda7a230ac

YD-677 Resolved multithreading issue pass-through headers (#585) * YD-677 Resolved multithreading issue pass-through headers The issue was that we were trying to inject a thread-scoped bean into a singleton bean. However, the injection on a singleton bean happens only once, so the same PassThroughHeaders instance was used on all threads. Added a test that reproduces the issue, created a straightforward fix and removed the thread-scope stuff. * YD-677 Processed review comments * Corrected spelling of path element on TestController from passThrougHeaders to passThroughHeaders * Renamed barrier in TestController to be more clear about the scope and purpose * PassThroughHeadersHolder now clears the map upon a fresh importFrom or readFrom

view details

Bert Roos

commit sha 39d344eebdcc116b93a331e86e8f0dce4a208307

YD-676 Clear Firebase ID if not registered anymore (#584) * YD-676 Clear Firebase ID if not registered anymore If the Firebase instance ID is not registered anymore, the Firbase web service returns a 404. In that case, we clear the Firebase instance ID on the DeviceAnonymized entity, so we stop trying to push notifications to that device. Along with this: * Added a method to find a DeviceAnonymized without having the UserAnonymized ID available. That ID would otherwise be used for logging, but that isn't worth carrying the UserAnonymized around. * Used the Spring-way of asynchronous execution. This way, the thread is automatically initialized for Spring behavior. * Fixed an issue in the Groovy Firebase tests that caused intermittent failures because the asynchronous execution wasn't completed before the Firebase message was fetched by the test * Created a unit test for AsyncExecutor * Made the AsyncExecutor clear the MDC and header holder upon completion of the task * YD-676 Corrected modifier order on FIREBASE_ID_NOT_REGISTERED constant * YD-676 Processed review comment More clear assertions

view details

Bert Roos

commit sha 847bb51260724e037b1112278f7923fcbd946b09

YD-676 Use getHeadersMap() instead of storedHeaders

view details

Bert Roos

commit sha f071b80f16eaa761c4fdd94ac40e2d981132cf0c

YD-676 Log Firebase error code We currently check for registration-token-not-registered, but it's apparently different.

view details

Bert Roos

commit sha e233ef2cc2360720700dbfafdcb167772dfe3e5b

YD-676 Check inner exception The FirebaseMessagingException is wrapped in a FirebaseServiceException, so we should check the inner exception for the error code.

view details

Bert Roos

commit sha 0740a35c86cc38f75f801dc634cb27eceed4652f

Merge branch 'master' into yd-659-spring-boot-221

view details

push time in 9 days

push eventyonadev/yona-server

Bert Roos

commit sha e233ef2cc2360720700dbfafdcb167772dfe3e5b

YD-676 Check inner exception The FirebaseMessagingException is wrapped in a FirebaseServiceException, so we should check the inner exception for the error code.

view details

push time in 9 days

push eventyonadev/yona-server

Bert Roos

commit sha f071b80f16eaa761c4fdd94ac40e2d981132cf0c

YD-676 Log Firebase error code We currently check for registration-token-not-registered, but it's apparently different.

view details

push time in 9 days

push eventyonadev/yona-server

Bert Roos

commit sha 847bb51260724e037b1112278f7923fcbd946b09

YD-676 Use getHeadersMap() instead of storedHeaders

view details

push time in 11 days

Pull request review commentyonadev/yona-server

YD-676 Clear Firebase ID if not registered anymore

+/*******************************************************************************+ * Copyright (c) 2020 Stichting Yona Foundation This Source Code Form is subject to the terms of the Mozilla Public License,+ * v.2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.+ *******************************************************************************/+package nu.yona.server.util;++import static org.hamcrest.CoreMatchers.is;+import static org.hamcrest.MatcherAssert.assertThat;+import static org.junit.jupiter.api.Assertions.assertEquals;+import static org.junit.jupiter.api.Assertions.assertNotEquals;++import java.util.Map;+import java.util.Optional;+import java.util.UUID;+import java.util.concurrent.CountDownLatch;++import org.junit.jupiter.api.Test;+import org.junit.jupiter.api.extension.ExtendWith;+import org.slf4j.MDC;+import org.springframework.beans.factory.annotation.Autowired;+import org.springframework.context.annotation.ComponentScan;+import org.springframework.context.annotation.Configuration;+import org.springframework.context.annotation.FilterType;+import org.springframework.scheduling.annotation.EnableAsync;+import org.springframework.test.context.ContextConfiguration;+import org.springframework.test.context.junit.jupiter.SpringExtension;++import nu.yona.server.entities.UserRepositoriesConfiguration;+import nu.yona.server.rest.PassThroughHeadersHolder;++@Configuration+@EnableAsync+@ComponentScan(useDefaultFilters = false, basePackages = { "nu.yona.server.rest", "nu.yona.server.util" }, includeFilters = {+		@ComponentScan.Filter(pattern = "nu.yona.server.rest.PassThroughHeadersHolder", type = FilterType.REGEX),+		@ComponentScan.Filter(pattern = "nu.yona.server.util.AsyncExecutor", type = FilterType.REGEX) })+class AsyncExecutorTestConfiguration extends UserRepositoriesConfiguration+{+}++@ExtendWith(SpringExtension.class)+@ContextConfiguration(classes = { AsyncExecutorTestConfiguration.class })+class AsyncExecutorTest+{+	@Autowired+	private AsyncExecutor service;++	@Autowired+	private PassThroughHeadersHolder headersHolder;++	@Test+	void getThreadData_successful_dataIsPresent() throws InterruptedException+	{+		DataCarrier expectedData = initializeThread();+		CountDownLatch doneSignal = new CountDownLatch(1);+		DataCarrier actionHandlerData = new DataCarrier();+		DataCarrier completionHandlerData = new DataCarrier();++		service.execAsync(service.getThreadData(), () -> actionHandler(actionHandlerData, Optional.empty()),+				(t) -> completionHandler(doneSignal, completionHandlerData, t));+		doneSignal.await();++		assertReturnedData(completionHandlerData, expectedData);+		assertReturnedData(actionHandlerData, expectedData);+	}++	@Test+	void getThreadData_failed_dataIsPresentThrowableIsAvailable() throws InterruptedException+	{+		DataCarrier expectedData = initializeThread();+		expectedData.exception = Optional.of(new NullPointerException("This fails badly"));+		CountDownLatch doneSignal = new CountDownLatch(1);+		DataCarrier actionHandlerData = new DataCarrier();+		DataCarrier completionHandlerData = new DataCarrier();++		service.execAsync(service.getThreadData(), () -> actionHandler(actionHandlerData, expectedData.exception),+				(t) -> completionHandler(doneSignal, completionHandlerData, t));+		doneSignal.await();++		assertReturnedData(completionHandlerData, expectedData);+		expectedData.exception = Optional.empty();

I'don't see why we shouldn't assert the data of the action handler at the time it will fail. That's still valid to check. Sure, we could omit that entire assert, as it's covered by the first test already, but in the second test it needs to have the same values before it fails. Three tests doesn't add anything, as there are only two scenarios:

  • The action handler succeeds
  • The action handler fails

In either case, the action handler and the completion handler need to have all data and in the failure case, the completion handler also needs to have the exception.

Bert-R

comment created time in 12 days

pull request commentyonadev/yona-server

YD-677 Resolved multithreading issue pass-through headers

Pushed an update

Bert-R

comment created time in 12 days

pull request commentyonadev/yona-server

YD-676 Clear Firebase ID if not registered anymore

Pushed an update

Bert-R

comment created time in 12 days

push eventyonadev/yona-server

Bert Roos

commit sha 9cb336af6aedb5ff54d67330413b3442e0dfa93d

YD-677 Processed review comments * Corrected spelling of path element on TestController from passThrougHeaders to passThroughHeaders * Renamed barrier in TestController to be more clear about the scope and purpose * PassThroughHeadersHolder now clears the map upon a fresh importFrom or readFrom

view details

push time in 12 days

Pull request review commentyonadev/yona-server

YD-677 Resolved multithreading issue pass-through headers

 private FirebaseMessageResourceAssembler createFirebaseMessageResourceAssembler( 		return new FirebaseMessageResourceAssembler(); 	} +	/**+	 * Returns the headers stored in the {@link PassThroughHeadersHolder}. This method blocks till a second request is done, thus+	 * enforcing multithreading.+	 * +	 * @return the headers stored in the {@link PassThroughHeadersHolder}+	 */+	@GetMapping(value = "/passThrougHeaders")+	@ResponseBody+	public HttpEntity<PassThroughHeadersResource> getPassThroughHeaders()+	{+		Require.that(yonaProperties.isTestServer(),+				() -> InvalidDataException.onlyAllowedOnTestServers("Endpoint /passThrougHeaders is not available"));

You're suffering from a similar issue :) passTrougHeaders -> passThrougHeaders -> passThroughHeaders

Bert-R

comment created time in 12 days

Pull request review commentyonadev/yona-server

YD-677 Resolved multithreading issue pass-through headers

 	@Autowired 	private FirebaseService firebaseService; +	@Autowired+	private PassThroughHeadersHolder headersHolder;++	private final CyclicBarrier barrier = new CyclicBarrier(2);

Agreed.

Bert-R

comment created time in 12 days

Pull request review commentyonadev/yona-server

YD-677 Resolved multithreading issue pass-through headers

 private FirebaseMessageResourceAssembler createFirebaseMessageResourceAssembler( 		return new FirebaseMessageResourceAssembler(); 	} +	/**+	 * Returns the headers stored in the {@link PassThroughHeadersHolder}. This method blocks till a second request is done, thus+	 * enforcing multithreading.+	 * +	 * @return the headers stored in the {@link PassThroughHeadersHolder}+	 */+	@GetMapping(value = "/passThrougHeaders")

Sharp!

Bert-R

comment created time in 12 days

Pull request review commentyonadev/yona-server

YD-677 Resolved multithreading issue pass-through headers

 import java.util.HashMap; import java.util.Map; +import org.springframework.core.NamedThreadLocal; import org.springframework.http.HttpHeaders;+import org.springframework.stereotype.Component;  /**  * Holds the headers that are received in an incoming HTTP request, which needs to be passed-through in outgoing HTTP requests.  * See {@link HeadersServerInterceptor} for the place where the incoming headers are stored in the holder and  * {@link HeadersClientInterceptor} for the place where the headers are read.  */+@Component public class PassThroughHeadersHolder {-	private final Map<String, String> storedHeaders = new HashMap<>();+	private final ThreadLocal<Map<String, String>> threadLocal = new NamedThreadLocal<Map<String, String>>(

I'm going to clear it as part of readFrom and importFrom.

Bert-R

comment created time in 12 days

Pull request review commentyonadev/yona-server

YD-677 Resolved multithreading issue pass-through headers

 import java.util.HashMap; import java.util.Map; +import org.springframework.core.NamedThreadLocal; import org.springframework.http.HttpHeaders;+import org.springframework.stereotype.Component;  /**  * Holds the headers that are received in an incoming HTTP request, which needs to be passed-through in outgoing HTTP requests.  * See {@link HeadersServerInterceptor} for the place where the incoming headers are stored in the holder and  * {@link HeadersClientInterceptor} for the place where the headers are read.  */+@Component public class PassThroughHeadersHolder {-	private final Map<String, String> storedHeaders = new HashMap<>();+	private final ThreadLocal<Map<String, String>> threadLocal = new NamedThreadLocal<Map<String, String>>(

Valid point. The threads can certainly be reused.

Bert-R

comment created time in 12 days

Pull request review commentyonadev/yona-server

YD-676 Clear Firebase ID if not registered anymore

+/*******************************************************************************+ * Copyright (c) 2020 Stichting Yona Foundation This Source Code Form is subject to the terms of the Mozilla Public License,+ * v.2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.+ *******************************************************************************/+package nu.yona.server.util;++import static org.hamcrest.CoreMatchers.is;+import static org.hamcrest.MatcherAssert.assertThat;+import static org.junit.jupiter.api.Assertions.assertEquals;+import static org.junit.jupiter.api.Assertions.assertNotEquals;++import java.util.Map;+import java.util.Optional;+import java.util.UUID;+import java.util.concurrent.CountDownLatch;++import org.junit.jupiter.api.Test;+import org.junit.jupiter.api.extension.ExtendWith;+import org.slf4j.MDC;+import org.springframework.beans.factory.annotation.Autowired;+import org.springframework.context.annotation.ComponentScan;+import org.springframework.context.annotation.Configuration;+import org.springframework.context.annotation.FilterType;+import org.springframework.scheduling.annotation.EnableAsync;+import org.springframework.test.context.ContextConfiguration;+import org.springframework.test.context.junit.jupiter.SpringExtension;++import nu.yona.server.entities.UserRepositoriesConfiguration;+import nu.yona.server.rest.PassThroughHeadersHolder;++@Configuration+@EnableAsync+@ComponentScan(useDefaultFilters = false, basePackages = { "nu.yona.server.rest", "nu.yona.server.util" }, includeFilters = {+		@ComponentScan.Filter(pattern = "nu.yona.server.rest.PassThroughHeadersHolder", type = FilterType.REGEX),+		@ComponentScan.Filter(pattern = "nu.yona.server.util.AsyncExecutor", type = FilterType.REGEX) })+class AsyncExecutorTestConfiguration extends UserRepositoriesConfiguration+{+}++@ExtendWith(SpringExtension.class)+@ContextConfiguration(classes = { AsyncExecutorTestConfiguration.class })+class AsyncExecutorTest+{+	@Autowired+	private AsyncExecutor service;++	@Autowired+	private PassThroughHeadersHolder headersHolder;++	@Test+	void getThreadData_successful_dataIsPresent() throws InterruptedException+	{+		DataCarrier expectedData = initializeThread();+		CountDownLatch doneSignal = new CountDownLatch(1);+		DataCarrier actionHandlerData = new DataCarrier();+		DataCarrier completionHandlerData = new DataCarrier();++		service.execAsync(service.getThreadData(), () -> actionHandler(actionHandlerData, Optional.empty()),+				(t) -> completionHandler(doneSignal, completionHandlerData, t));+		doneSignal.await();++		assertReturnedData(completionHandlerData, expectedData);+		assertReturnedData(actionHandlerData, expectedData);+	}++	@Test+	void getThreadData_failed_dataIsPresentThrowableIsAvailable() throws InterruptedException+	{+		DataCarrier expectedData = initializeThread();+		expectedData.exception = Optional.of(new NullPointerException("This fails badly"));+		CountDownLatch doneSignal = new CountDownLatch(1);+		DataCarrier actionHandlerData = new DataCarrier();+		DataCarrier completionHandlerData = new DataCarrier();++		service.execAsync(service.getThreadData(), () -> actionHandler(actionHandlerData, expectedData.exception),+				(t) -> completionHandler(doneSignal, completionHandlerData, t));+		doneSignal.await();++		assertReturnedData(completionHandlerData, expectedData);+		expectedData.exception = Optional.empty();

I've created two assertion methods. That makes it clear what's being asserted.

Bert-R

comment created time in 12 days

push eventyonadev/yona-server

Bert Roos

commit sha 5a1c3941aec23f9ddc40eceefd9862f0371f510e

YD-676 Processed review comment More clear assertions

view details

push time in 12 days

Pull request review commentyonadev/yona-server

YD-676 Clear Firebase ID if not registered anymore

+/*******************************************************************************+ * Copyright (c) 2020 Stichting Yona Foundation This Source Code Form is subject to the terms of the Mozilla Public License,+ * v.2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.+ *******************************************************************************/+package nu.yona.server.util;++import static org.hamcrest.CoreMatchers.is;+import static org.hamcrest.MatcherAssert.assertThat;+import static org.junit.jupiter.api.Assertions.assertEquals;+import static org.junit.jupiter.api.Assertions.assertNotEquals;++import java.util.Map;+import java.util.Optional;+import java.util.UUID;+import java.util.concurrent.CountDownLatch;++import org.junit.jupiter.api.Test;+import org.junit.jupiter.api.extension.ExtendWith;+import org.slf4j.MDC;+import org.springframework.beans.factory.annotation.Autowired;+import org.springframework.context.annotation.ComponentScan;+import org.springframework.context.annotation.Configuration;+import org.springframework.context.annotation.FilterType;+import org.springframework.scheduling.annotation.EnableAsync;+import org.springframework.test.context.ContextConfiguration;+import org.springframework.test.context.junit.jupiter.SpringExtension;++import nu.yona.server.entities.UserRepositoriesConfiguration;+import nu.yona.server.rest.PassThroughHeadersHolder;++@Configuration+@EnableAsync+@ComponentScan(useDefaultFilters = false, basePackages = { "nu.yona.server.rest", "nu.yona.server.util" }, includeFilters = {+		@ComponentScan.Filter(pattern = "nu.yona.server.rest.PassThroughHeadersHolder", type = FilterType.REGEX),+		@ComponentScan.Filter(pattern = "nu.yona.server.util.AsyncExecutor", type = FilterType.REGEX) })+class AsyncExecutorTestConfiguration extends UserRepositoriesConfiguration+{+}++@ExtendWith(SpringExtension.class)+@ContextConfiguration(classes = { AsyncExecutorTestConfiguration.class })+class AsyncExecutorTest+{+	@Autowired+	private AsyncExecutor service;++	@Autowired+	private PassThroughHeadersHolder headersHolder;++	@Test+	void getThreadData_successful_dataIsPresent() throws InterruptedException+	{+		DataCarrier expectedData = initializeThread();+		CountDownLatch doneSignal = new CountDownLatch(1);+		DataCarrier actionHandlerData = new DataCarrier();+		DataCarrier completionHandlerData = new DataCarrier();++		service.execAsync(service.getThreadData(), () -> actionHandler(actionHandlerData, Optional.empty()),+				(t) -> completionHandler(doneSignal, completionHandlerData, t));+		doneSignal.await();++		assertReturnedData(completionHandlerData, expectedData);+		assertReturnedData(actionHandlerData, expectedData);+	}++	@Test+	void getThreadData_failed_dataIsPresentThrowableIsAvailable() throws InterruptedException+	{+		DataCarrier expectedData = initializeThread();+		expectedData.exception = Optional.of(new NullPointerException("This fails badly"));+		CountDownLatch doneSignal = new CountDownLatch(1);+		DataCarrier actionHandlerData = new DataCarrier();+		DataCarrier completionHandlerData = new DataCarrier();++		service.execAsync(service.getThreadData(), () -> actionHandler(actionHandlerData, expectedData.exception),+				(t) -> completionHandler(doneSignal, completionHandlerData, t));+		doneSignal.await();++		assertReturnedData(completionHandlerData, expectedData);+		expectedData.exception = Optional.empty();

How about extending assertReturnedData with a parameter to indicate it's asserting action data or assertion data? Or even making two methods for it?

Bert-R

comment created time in 12 days

pull request commentyonadev/yona-app

APPDEV-1297 Log the exception, not just the message

Eens. Iets voor een volgende update. Ik heb op het ogenblik geen ontwikkelomgeving voor de app, dus ik moet het in een teksteditor doen. Dat is een beetje tricky als je niet eens weet hoe je moet compileren.

Bert-R

comment created time in 12 days

PR opened yonadev/yona-app

APPDEV-1297 Log the exception, not just the message

This fixes the NPE and improves the logging

+2 -2

0 comment

1 changed file

pr created time in 14 days

create barnchyonadev/yona-app

branch : appdev-1297-npe-in-logger

created branch time in 14 days

PR opened yonadev/yona-server

YD-677 Resolved multithreading issue pass-through headers

The issue was that we were trying to inject a thread-scoped bean into a singleton bean. However, the injection on a singleton bean happens only once, so the same PassThroughHeaders instance was used on all threads.

Added a test that reproduces the issue, created a straightforward fix and removed the thread-scope stuff.

+192 -78

0 comment

6 changed files

pr created time in 16 days

create barnchyonadev/yona-server

branch : yd-677-multithreading-issue

created branch time in 16 days

Pull request review commentyonadev/yona-server

YD-676 Clear Firebase ID if not registered anymore

 public ThreadData getThreadData() 		return new ThreadData(MDC.getCopyOfContextMap(), headersHolder.export()); 	} -	public void initThreadAndDo(ThreadData threadData, Runnable action)+	@Async+	public void execAsync(ThreadData threadData, Runnable action, Consumer<Optional<Throwable>> completionHandler) 	{-		threadData.contextMap.ifPresent(MDC::setContextMap);-		headersHolder.importFrom(threadData.headers);-		action.run();+		try (Handler handler = Handler.initialize(headersHolder, threadData))+		{+			try+			{+				action.run();+				completionHandler.accept(Optional.empty());+			}+			catch (Throwable e)

Here we really want to catch Throwable

Bert-R

comment created time in 20 days

push eventyonadev/yona-server

Bert Roos

commit sha ec1ca0a5dbfc007e9a870f98a19237694604384a

YD-676 Corrected modifier order on FIREBASE_ID_NOT_REGISTERED constant

view details

push time in 20 days

PR opened yonadev/yona-server

YD-676 Clear Firebase ID if not registered anymore

If the Firebase instance ID is not registered anymore, the Firbase web service returns a 404. In that case, we clear the Firebase instance ID on the DeviceAnonymized entity, so we stop trying to push notifications to that device.

Along with this:

  • Added a method to find a DeviceAnonymized without having the UserAnonymized ID available. That ID would otherwise be used for logging, but that isn't worth carrying the UserAnonymized around.
  • Used the Spring-way of asynchronous execution. This way, the thread is automatically initialized for Spring behavior.
  • Fixed an issue in the Groovy Firebase tests that caused intermittent failures because the asynchronous execution wasn't completed before the Firebase message was fetched by the test
  • Created a unit test for AsyncExecutor
  • Made the AsyncExecutor clear the MDC and header holder upon completion of the task
+261 -26

0 comment

11 changed files

pr created time in 20 days

create barnchyonadev/yona-server

branch : yd-676-clear-firebase-id

created branch time in 20 days

push eventyonadev/yona-server

Bert Roos

commit sha 937ca1b7b6a29b09513f198981805bd1565ac302

YD-669 Init thread context on completion logging

view details

Bert Roos

commit sha f78c5776f5827b72bcaa0108a870c14616658f93

Merge branch 'master' of https://github.com/yonadev/yona-server

view details

push time in 23 days

push eventyonadev/yona-server

Bert Roos

commit sha 568eb38bf627b840e6813849bd92e393bf40a93c

YD-675 Cover mandatory goal creation date scenario

view details

push time in a month

push eventyonadev/yona-server

Bert Roos

commit sha c730cef0e32ecb3f0d7f1d51f3ff2ad24764329e

YD-675 Processed review comment Added unit test for IntervalActivity.hasPrevious

view details

push time in a month

push eventyonadev/yona-server

Bert Roos

commit sha 21abdedafe83b318eec9dad500c37dfe01d2e126

YD-659 Upgraded to Spring Boot 2.2.4 The issue that triggered the upgrade to Gradle 6.1 (spring-projects/spring-boot#19783) is resolved in this version, so strictly speaking, we can stick with the previous version of Gradle (and the Docker plug-in), but everything works, so let's move along.

view details

push time in a month

push eventyonadev/yona-server

Bert Roos

commit sha 97587c3c8e6578b50ef88c64b45391ce5dae5d00

Extra logging to track down Firebase issue

view details

push time in a month

Pull request review commentyonadev/yona-server

YD-675 Corrected prev links on day/week details

 class ActivityTest extends AbstractAppServiceIntegrationTest 		appService.deleteUser(richard) 	} -	def 'Retrieve activity report of previous week'()+	def 'Retrieve activity report of previous weeks'()

Done.

Bert-R

comment created time in a month

push eventyonadev/yona-server

Bert Roos

commit sha 77e93a89461ebb1fe14f18978a30464aabac4029

YD-675 Navigation link assessment is a separate test

view details

push time in a month

Pull request review commentyonadev/yona-server

YD-675 Corrected prev links on day/week details

 class ActivityTest extends AbstractAppServiceIntegrationTest 		appService.deleteUser(richard) 	} -	def 'Retrieve activity report of previous week'()+	def 'Retrieve activity report of previous weeks'()

I'm going to revert this change and instead make a test "Richard gets proper navigation links between day and week details". That'll be easier to understand.

Bert-R

comment created time in a month

create barnchyonadev/yona-server

branch : yd-675-details-prev-link

created branch time in a month

push eventyonadev/yona-server

Bert Roos

commit sha 6cd98ad12f4b73f5d965817fdb1bc2ec5b3c0096

YD-673 Mark fatal issues with ALERT (#581) This is done for internal server errors occurring in HTTP requests and for asynchronous processes (Quartz jobs, batch jobs and async tasks (CompletableFuture.runAsync). Along with this: * Renamed nu.yona.server.rest.Constants into RestConstants, to prevent clashes in places where both are needed * The PASSWORD_HEADER constant was mostly statically imported. Did this now everywhere.

view details

push time in a month

PR merged yonadev/yona-server

YD-673 Mark fatal issues with ALERT

This is done for internal server errors occurring in HTTP requests and for asynchronous processes (Quartz jobs, batch jobs and async tasks (CompletableFuture.runAsync).

Along with this:

  • Renamed nu.yona.server.rest.Constants into RestConstants, to prevent clashes in places where both are needed
  • The PASSWORD_HEADER constant was mostly statically imported. Did this now everywhere.
+194 -88

1 comment

24 changed files

Bert-R

pr closed time in a month

push eventyonadev/yona-server

Bert Roos

commit sha 4a13206de199804d256e4889e52e1b638e8f8595

YD-671 Remove values.yaml on completion of helm upgrade

view details

Bert Roos

commit sha 55608895220cae78bbb0d6962f34cc1c20496047

YD-671 Don't store values.yaml on the file system anymore And put the token in the environment rather than on the command line

view details

Bert Roos

commit sha 6f10886ecfe8575bf0be21ff16c35b938cd02735

YD-671 Removed valuesYamlPath

view details

Bert Roos

commit sha e9c13ec3c99a87132985c87a75824208d511dfa9

YD-669 Pass app info all the way (#580) * YD-669 Pass app info all the way It now goes from the app service to invoked services (e.g. the analysis service) and also to the async thread that sends the Firebase message, so it can be included in the error logging there. Along with this: * Improved the error logging for errors returned from an invoked service * YD-669 Consistent arg order params, headers We used to have methods that take just an argument "parameters" and overwriting methods that use "headers, parameters", both optional. This lead to inconsistencies. Sometimes the single given argument is "parameters", sometimes it's "headers". Now the parameter order is always "parameters, headers". * YD-669 Include the token in the error message When an Firebase exception occurs. * YD-669 Addressed SonarQube review comment Replaced lambda call with method reference * YD-671 Corrected path 'infrastructure' only prefixes the path for the regression test server, not for the other servers. * YD-669 Addressed review comments: * Better name for HeadersHolder * Better variable names in FirebaseTest * Added some comments * YD-669 Explained pass through headers approach In class-level comments. * YD-669 Addressed review comments * Spelling correction in comment in HeadersServerInterceptor * Corrected private method PassThroughHeadersHolder.storeIfPresent (it didn't use the name parameter in all necessary places)

view details

Bert Roos

commit sha 527f586f15ba00f9932d459bb9a335ed0280d8d2

Merge branch 'master' into yd-673-mark-alerts

view details

push time in a month

pull request commentyonadev/yona-server

YD-659 Upgrade to Spring Boot 2.2.2

Pushed an update

Bert-R

comment created time in a month

push eventyonadev/yona-server

Bert Roos

commit sha ebd884da332813f531ab6c49f6208fbbb1068874

YD-659 Addressed review comments * Corrected comment in SecurityProperties (was accidentally updated by Spring HATEOAS upgrade script) * Corrected comment in CreateUserOnBuddyRequestTest.Hacking attempt: Try to get a user created on buddy request with normal Yona password header() * Replaced ActivityControllerBase.PREV_REL and ActivityControllerBase.NEXT_REL with IanaLinkRelations.PREV and IanaLinkRelations.NEXT respectively. * Replaced JsonRootLinkRelationProvider.EDIT_REL with IanaLinkRelations.EDIT

view details

push time in a month

Pull request review commentyonadev/yona-server

YD-659 Upgrade to Spring Boot 2.2.2

 class CreateUserOnBuddyRequestTest extends AbstractAppServiceIntegrationTest 		User richard = addRichard() 		def mobileNumberBob = makeMobileNumber(timestamp) 		def responseAddBuddy = sendBuddyRequestForBobby(richard, mobileNumberBob)-		// Take invite URL and remove "tempPassword=abcd&" or "&tempPassword=abcd" (varying order occurs)-		def urlToTry = getInviteUrl().replaceFirst(/tempPassword=[^&]*&/, "").replaceFirst(/&tempPassword=[^&]*/, "")+		// Take invite URL and remove "tempPassword=abcd&" or "&tempPassword=ab&cd" (varying order occurs)

It wasn't only confusing, it was wrong. Corrected it into:

// Take invite URL and remove "tempPassword=ab%26cd&" or "&tempPassword=ab%26cd" (varying order occurs)
Bert-R

comment created time in a month

Pull request review commentyonadev/yona-server

YD-659 Upgrade to Spring Boot 2.2.2

 	protected static final int WEEKS_DEFAULT_PAGE_SIZE = 2; 	protected static final int DAYS_DEFAULT_PAGE_SIZE = 3; 	protected static final int MESSAGES_DEFAULT_PAGE_SIZE = 4;-	protected static final String PREV_REL = "prev"; // IANA reserved, so will not be prefixed

Yes, good one. Done.

Bert-R

comment created time in a month

Pull request review commentyonadev/yona-server

YD-659 Upgrade to Spring Boot 2.2.2

 private void addActivityCategoryLink(GoalDto goalResource) 		}  		@Override-		protected GoalDto instantiateResource(GoalDto goal)+		protected GoalDto instantiateModel(GoalDto goal) 		{ 			return goal; 		} -		private void addSelfLink(ControllerLinkBuilder selfLinkBuilder, GoalDto goalResource)+		private void addSelfLink(WebMvcLinkBuilder selfLinkBuilder, GoalDto goalResource) 		{ 			goalResource.add(selfLinkBuilder.withSelfRel()); 		} -		private void addEditLink(ControllerLinkBuilder selfLinkBuilder, GoalDto goalResource)+		private void addEditLink(WebMvcLinkBuilder selfLinkBuilder, GoalDto goalResource) 		{-			goalResource.add(selfLinkBuilder.withRel(JsonRootRelProvider.EDIT_REL));+			goalResource.add(selfLinkBuilder.withRel(JsonRootLinkRelationProvider.EDIT_REL));

Yes, that's possible. Done.

Bert-R

comment created time in a month

Pull request review commentyonadev/yona-server

YD-659 Upgrade to Spring Boot 2.2.2

 	private String ovpnProfileFile;  	/**-	 * If true, Cross Origin Resource Sharing is allowed. This is necessary for Swagger UI.+	 * If true, Cross Origin EntityModel Sharing is allowed. This is necessary for Swagger UI.

:) This is a funny one caused by the Spring HATEOAS migration script. I'll correct it.

Bert-R

comment created time in a month

Pull request review commentyonadev/yona-server

YD-659 Upgrade to Spring Boot 2.2.2

 public DayActivityOverviewWithBuddiesResource(UUID requestingUserId, UUID reques  		public List<DayActivityWithBuddiesResource> getDayActivities() 		{-			return new DayActivityWithBuddiesResourceAssembler(requestingUserId, requestingDeviceId, goalIdMapping,-					getContent().getDateStr()).toResources(getContent().getDayActivities());+			CollectionModel<DayActivityWithBuddiesResource> collectionModel = new DayActivityWithBuddiesResourceAssembler(+					requestingUserId, requestingDeviceId, goalIdMapping, getContent().getDateStr())+							.toCollectionModel(getContent().getDayActivities());+			return Lists.newArrayList(collectionModel);

We're using Guava in two more places. This is a common way to convert an Iterable into a List for people that use Guava.

Bert-R

comment created time in a month

push eventyonadev/yona-server

Bert Roos

commit sha 8d45ade81c019bf4276a99d579dcc14b39aaae32

YD-667 add requestingDeviceId for act withBuddies

view details

Bert Roos

commit sha f0fcbb5e297d5b5f6b89da31910595609c9964f4

Use {0} for error.request.only.allowed.on.test.server

view details

Bert Roos

commit sha c81dd85b2a85b100ce684e917b5cf923a4920ea2

Corrected path in InvalidDataException

view details

Bert Roos

commit sha 57a0c3121bb1765fee179df2437eeff90ca9b8fb

YD-667 Cleanup and correction * Removed unnecessary extractors * Renamed "User &amp; Buddy Day" into "User with buddies Day". Same for "Buddy &amp; ..." * Renamed "UserandBuddyDayDetailsNextUrl" into "UserWithBuddiesNextUrl". Same for "Buddyand..." * Removed "details" in cases where it referred to a day or week overview * Removed _1 from the ...NextUrl variables

view details

Bert Roos

commit sha 3f17e76a865fd06682d43e717dfdda0bc901b84e

YD-667 Don't use variable for next URL The samplers for fetching the first and next page are being executed in random order, so the value for the 'next' URL might not yet be available when fetching the next page, as the next page might be fetched before the first one (random order!). Now the next page simply adds "page=1" to the path.

view details

Bert Roos

commit sha 485159c32bffc37ce2e64a3202e40886a19e25a2

YD-667 Set user creation time For goals, it was already possible to set the creation time when creating the goal. This is now possible for users too, provided the server is configured as test server (this check was missing for goals). The load test makes use of this new feature, to enable paging through day and week activities.

view details

Bert Roos

commit sha c46bf73a3a2408b7541d3a6c74d8f0d69e9ba15f

YD-667 Set buddy rel last status change time This allows paging backward through activities "withBuddies". Along with this: * Corrected hint in BuddyService.updateLastStatusChangeTime

view details

Bert Roos

commit sha 87afd40fb6bda79318850b4033ca870ab0e618e0

YD-667 Use correct password variable Used the password of the buddy user instead of the user itself

view details

Bert Roos

commit sha 746fe78f3794873882294ce19fc84861e0bef97c

YD-671 First step toward fetching values.yaml Introduced function. Getting the basics to work first.

view details

Bert Roos

commit sha afb3b13e79bcb1cea97c1ec8e97b8053901b47bc

YD-671 Move variable outside pipeline

view details

Bert Roos

commit sha 4d72a0747373eddb62dffc5792a6c6b4bf816f8c

YD-671 Use real credential And a different way to reference the variable

view details

Bert Roos

commit sha 490a940641db0be91fa8585c7aa0238b0916559a

YD-671 Debugging

view details

Bert Roos

commit sha ccfd47a185351fad33585a39a95c6653080e1160

YD-671 Debugging

view details

Bert Roos

commit sha 641ae3402efb6da5cd0259ac68f4ca7c00f7897e

YD-671 Use withCredentials

view details

Bert Roos

commit sha ecb0882e10a02b9191ab640629178770f6277f71

YD-671 Fail on error Output to values.yaml and create target folder if non-existing.

view details

Bert Roos

commit sha 236132b05504facd81df03f5cef279fac6126c3e

YD-671 Use correct credential

view details

Bert Roos

commit sha 88ecec570fca1796673eafd0d23f89262a46b573

YD-671 Use full path for values.yaml

view details

Bert Roos

commit sha b560b0bb12306c0486d0a3e31d33c7e874f97ae2

YD-671 Use withCredentials inside getValuesYaml

view details

Bert Roos

commit sha d72dca9a2cae3d090a5ed040ab45316f676f14cd

YD-671 Fetch values.yaml from GitLab for all envs

view details

Bert Roos

commit sha da0e2f1d35c2d0045d163eaf3187970e45c550fc

YD-668 Do not allow leading zeros in mobile nr (#578) * YD-668 Do not allow leading zeros in mobile nr Till now, we allowed numbers like +3106..., with a zero (could even be more than one) between the country code and the rest of the number. It looks like the mobile number confirmation logic generally doesn't work in that case, as only one user has a confirmed number of this format. However, if they use it to fetch a new device request, that fails. Similar issues exist when inviting buddies. With this change, such numbers are not allowed anymore. * Triggering another PR build * YD-668 Generalized translator mock And used it in UserAssertionServiceTest.java * YD-668 Addressed review comment Added explanatory comment

view details

push time in a month

push eventyonadev/yona-server

Bert Roos

commit sha c31ba29d3fdf61c0c8e5966c71a5024323d7b330

YD-659 Upgraded to Spring Boot 2.2.3 This caused an issue that is resolved in Gradle 6.1, so upgraded to that. That however requires a newer version of the Gradle Docker plugin, so upgraded that to the latest version (6.1.2)

view details

push time in a month

Pull request review commentyonadev/yona-server

YD-673 Mark fatal issues with ALERT

 /*******************************************************************************- * Copyright (c) 2015, 2019 Stichting Yona Foundation This Source Code Form is subject to the terms of the Mozilla Public License,+ * Copyright (c) 2015, 2020 Stichting Yona Foundation This Source Code Form is subject to the terms of the Mozilla Public License,  * v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.  *******************************************************************************/ package nu.yona.server.rest; -public final class Constants+public final class RestConstants { 	public static final String PASSWORD_HEADER = "Yona-Password"; 	public static final String NEW_DEVICE_REQUEST_PASSWORD_HEADER = "Yona-NewDeviceRequestPassword";

This obviously is a false positive.

Bert-R

comment created time in a month

Pull request review commentyonadev/yona-server

YD-673 Mark fatal issues with ALERT

 /*******************************************************************************- * Copyright (c) 2015, 2019 Stichting Yona Foundation This Source Code Form is subject to the terms of the Mozilla Public License,+ * Copyright (c) 2015, 2020 Stichting Yona Foundation This Source Code Form is subject to the terms of the Mozilla Public License,  * v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.  *******************************************************************************/ package nu.yona.server.rest; -public final class Constants+public final class RestConstants { 	public static final String PASSWORD_HEADER = "Yona-Password";

This obviously is a false positive.

Bert-R

comment created time in a month

pull request commentyonadev/yona-server

YD-669 Pass app info all the way

Pushed an update

Bert-R

comment created time in a month

push eventyonadev/yona-server

Bert Roos

commit sha 8965bb30aca831a90f3c02b30b828969d8c25b26

YD-669 Addressed review comments * Spelling correction in comment in HeadersServerInterceptor * Corrected private method PassThroughHeadersHolder.storeIfPresent (it didn't use the name parameter in all necessary places)

view details

push time in a month

create barnchyonadev/yona-server

branch : yd-674-sms-error-500

created branch time in a month

push eventyonadev/yona-server

Bert Roos

commit sha 6f10886ecfe8575bf0be21ff16c35b938cd02735

YD-671 Removed valuesYamlPath

view details

push time in a month

push eventyonadev/yona-server

Bert Roos

commit sha 55608895220cae78bbb0d6962f34cc1c20496047

YD-671 Don't store values.yaml on the file system anymore And put the token in the environment rather than on the command line

view details

push time in a month

push eventyonadev/yona-server

Bert Roos

commit sha 4a13206de199804d256e4889e52e1b638e8f8595

YD-671 Remove values.yaml on completion of helm upgrade

view details

push time in a month

PR opened yonadev/yona-server

YD-673 Mark fatal issues with ALERT

This is done for internal server errors occurring in HTTP requests and for asynchronous processes (Quartz jobs, batch jobs and async tasks (CompletableFuture.runAsync).

Along with this:

  • Renamed nu.yona.server.rest.Constants into RestConstants, to prevent clashes in places where both are needed
  • The PASSWORD_HEADER constant was mostly statically imported. Did this now everywhere.
+185 -79

0 comment

22 changed files

pr created time in a month

create barnchyonadev/yona-server

branch : yd-673-mark-alerts

created branch time in a month

push eventyonadev/yona-server

Bert Roos

commit sha 7d03cd6dbfb83c45a7c2f33de81353fe17d0c17c

YD-669 Explained pass through headers approach In class-level comments.

view details

push time in a month

Pull request review commentyonadev/yona-server

YD-669 Pass app info all the way

 private FirebaseMessageResourceAssembler createFirebaseMessageResourceAssembler( 		private final String title; 		private final String body; 		private final Map<String, String> data;+		private final String appOs;+		private final int appVersionCode;+		private final String appVersionName; -		public FirebaseMessageDto(String title, String body, Map<String, String> data)+		public FirebaseMessageDto(String title, String body, Map<String, String> data, String appOs, int appVersionCode,+				String appVersionName) 		{ 			this.title = title; 			this.body = body; 			this.data = data;+			this.appOs = appOs;+			this.appVersionCode = appVersionCode;+			this.appVersionName = appVersionName; 		}  		@SuppressWarnings("unchecked")-		public static FirebaseMessageDto createInstance(Message message)+		public static FirebaseMessageDto createInstance(MessageData messageData) 		{ 			try 			{-				Notification notification = (Notification) notificationField.get(message);-				Map<String, String> data = (Map<String, String>) dataField.get(message);+				Notification notification = (Notification) notificationField.get(messageData.firebaseMessage);+				Map<String, String> data = (Map<String, String>) dataField.get(messageData.firebaseMessage); 				String title = (String) titleField.get(notification); 				String body = (String) bodyField.get(notification);-				return new FirebaseMessageDto(title, body, data);+				String appOs = getStringValueFromMdc(messageData, Constants.APP_OS_MDC_KEY).orElse(null);

No. The headers holder is just a container/holder to hold the headers that are passed through in HTTP requests. We use some information that's communicated through headers as "mapped diagnostic context" in logging. The controller enables a test to see that the right information made it into this diagnostic context. It did so using the pass through headers solution, but the integration test verifies the result not the means.

Bert-R

comment created time in a month

Pull request review commentyonadev/yona-server

YD-669 Pass app info all the way

+/*******************************************************************************+ * Copyright (c) 2019 Stichting Yona Foundation This Source Code Form is subject to the terms of the Mozilla Public License,+ * v.2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.+ *******************************************************************************/+package nu.yona.server.rest;++import java.util.HashMap;+import java.util.Map;++import org.springframework.http.HttpHeaders;++public class HeadersHolder

The class provides the solution of holding headers that are passed through in HTTP requests. Not just app information, but HTTP headers. To me, the class name tells what it does. The earlier name said "it holds headers". The new name is specific about what headers it holds.

Bert-R

comment created time in a month

Pull request review commentyonadev/yona-server

YD-669 Pass app info all the way

+/*******************************************************************************+ * Copyright (c) 2019 Stichting Yona Foundation+ * This Source Code Form is subject to the terms of the Mozilla Public License,+ * v.2.0. If a copy of the MPL was not distributed with this file, You can+ * obtain one at https://mozilla.org/MPL/2.0/.+ *******************************************************************************/+package nu.yona.server.rest;++import java.io.IOException;++import org.springframework.http.HttpRequest;+import org.springframework.http.client.ClientHttpRequestExecution;+import org.springframework.http.client.ClientHttpRequestInterceptor;+import org.springframework.http.client.ClientHttpResponse;++public class HeadersClientInterceptor implements ClientHttpRequestInterceptor

All requests from one service to another, so from app to batch and from app to analysis

Bert-R

comment created time in a month

push eventyonadev/yona-server

Bert Roos

commit sha 3ec1df38ebd63fed1d5be51720649b94d9e2cf37

YD-671 Use double quotes To allow interpolation of variables

view details

push time in a month

push eventyonadev/yona-server

Bert Roos

commit sha 0aa5e482dddedae43288831660e43251606bb6e6

YD-671 Don't try to create the directory

view details

push time in a month

pull request commentyonadev/yona-server

YD-669 Pass app info all the way

Pushed an update

Bert-R

comment created time in a month

push eventyonadev/yona-server

Bert Roos

commit sha 380bd6711b1eaa2295df79e591d22922f4880d88

YD-671 Corrected path 'infrastructure' only prefixes the path for the regression test server, not for the other servers.

view details

Bert Roos

commit sha 1281888a08585c3372d1aa41664b0e0aafe5a23e

YD-671 Same path for value.yaml for all envs The build agent is not allowed to /config/values.yaml, as that is a read-only mount

view details

Bert Roos

commit sha d1235dd17737a341bbf038bdb3e463dd65f11115

YD-671 Put values.yaml in local working directory

view details

Bert Roos

commit sha 141e42e214afbce003ec2cd829239b5246552e24

Merge branch 'master' into yd-669-pass-app-info

view details

push time in a month

push eventyonadev/yona-server

Bert Roos

commit sha d1235dd17737a341bbf038bdb3e463dd65f11115

YD-671 Put values.yaml in local working directory

view details

push time in a month

push eventyonadev/yona-server

Bert Roos

commit sha 5d9c81d2dfe3b8800a42841e28682ae9f8638118

YD-669 Addressed review comments: * Better name for HeadersHolder * Better variable names in FirebaseTest * Added some comments

view details

push time in a month

Pull request review commentyonadev/yona-server

YD-669 Pass app info all the way

+/*******************************************************************************+ * Copyright (c) 2019 Stichting Yona Foundation This Source Code Form is subject to the terms of the Mozilla Public License,+ * v.2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.+ *******************************************************************************/+package nu.yona.server.rest;++import java.util.HashMap;+import java.util.Map;++import org.springframework.http.HttpHeaders;++public class HeadersHolder

What about PassThroughHeadersHolder? It holds 'headers', not just 'information', so I'd like to be more specific. At the other hand, it doesn't just hold headers, but the headers that are to be passed through from the incoming requests to the outgoing ones.

Bert-R

comment created time in a month

push eventyonadev/yona-server

Bert Roos

commit sha 1281888a08585c3372d1aa41664b0e0aafe5a23e

YD-671 Same path for value.yaml for all envs The build agent is not allowed to /config/values.yaml, as that is a read-only mount

view details

push time in a month

Pull request review commentyonadev/yona-server

YD-669 Pass app info all the way

 private FirebaseMessageResourceAssembler createFirebaseMessageResourceAssembler( 		private final String title; 		private final String body; 		private final Map<String, String> data;+		private final String appOs;+		private final int appVersionCode;+		private final String appVersionName; -		public FirebaseMessageDto(String title, String body, Map<String, String> data)+		public FirebaseMessageDto(String title, String body, Map<String, String> data, String appOs, int appVersionCode,+				String appVersionName) 		{ 			this.title = title; 			this.body = body; 			this.data = data;+			this.appOs = appOs;+			this.appVersionCode = appVersionCode;+			this.appVersionName = appVersionName; 		}  		@SuppressWarnings("unchecked")-		public static FirebaseMessageDto createInstance(Message message)+		public static FirebaseMessageDto createInstance(MessageData messageData) 		{ 			try 			{-				Notification notification = (Notification) notificationField.get(message);-				Map<String, String> data = (Map<String, String>) dataField.get(message);+				Notification notification = (Notification) notificationField.get(messageData.firebaseMessage);+				Map<String, String> data = (Map<String, String>) dataField.get(messageData.firebaseMessage); 				String title = (String) titleField.get(notification); 				String body = (String) bodyField.get(notification);-				return new FirebaseMessageDto(title, body, data);+				String appOs = getStringValueFromMdc(messageData, Constants.APP_OS_MDC_KEY).orElse(null);

The test controller is here to verify the firebase messaging and related logging. For that reason, it takes it from the place LogBack would take it from as well: the MDC. Makes sense?

Bert-R

comment created time in a month

Pull request review commentyonadev/yona-server

YD-669 Pass app info all the way

+/*******************************************************************************+ * Copyright (c) 2019 Stichting Yona Foundation+ * This Source Code Form is subject to the terms of the Mozilla Public License,+ * v.2.0. If a copy of the MPL was not distributed with this file, You can+ * obtain one at https://mozilla.org/MPL/2.0/.+ *******************************************************************************/+package nu.yona.server;++import org.springframework.context.annotation.Scope;++@Scope("thread")+public @interface ThreadScope

Agreed. Added a comment.

Bert-R

comment created time in a month

Pull request review commentyonadev/yona-server

YD-669 Pass app info all the way

 public void sendMessage(String registrationToken, nu.yona.server.messaging.entit 		Message firebaseMessage = Message.builder().setNotification(new Notification(title, body)) 				.putData("messageId", Long.toString(getMessageId(message))).setToken(registrationToken).build(); -		if (yonaProperties.getFirebase().isEnabled())-		{-			logger.info("Sending Firebase message");-			// Sending takes quite a bit of time, so do it asynchronously-			CompletableFuture.runAsync(() -> sendMessage(firebaseMessage))-					.whenCompleteAsync((r, t) -> logIfCompletedWithException(t));-		}-		else-		{-			logger.info("Firebase message not sent because Firebase is disabled");-			// Store for testability-			lastMessageByRegistrationToken.put(registrationToken, firebaseMessage);-		}+		// Sending takes quite a bit of time, so do it asynchronously+		ThreadData threadData = asyncExecutor.getThreadData();+		CompletableFuture+				.runAsync(() -> asyncExecutor.initThreadAndDo(threadData, () -> sendMessage(registrationToken, firebaseMessage)))+				.whenCompleteAsync((r, t) -> logIfCompletedWithException(t, registrationToken));

I don't think so. I believe I have manually verified this. If it is lacking, we'll need to add this in a separate PR.

Bert-R

comment created time in a month

Pull request review commentyonadev/yona-server

YD-669 Pass app info all the way

+/*******************************************************************************+ * Copyright (c) 2019 Stichting Yona Foundation+ * This Source Code Form is subject to the terms of the Mozilla Public License,+ * v.2.0. If a copy of the MPL was not distributed with this file, You can+ * obtain one at https://mozilla.org/MPL/2.0/.+ *******************************************************************************/+package nu.yona.server.rest;++import java.util.Collections;++import org.springframework.context.annotation.Bean;+import org.springframework.context.annotation.Configuration;+import org.springframework.web.client.RestTemplate;+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;++import com.fasterxml.jackson.databind.ObjectMapper;++import nu.yona.server.ThreadScope;++@Configuration+public class Config implements WebMvcConfigurer

It's a configuration (as indicated by the @Configuration annotation) with REST-related stuff (and that's indicated because it is in the nu.yona.server.rest package). Naming it WebMvcConfig would indicate a more narrow scope than that.

Bert-R

comment created time in a month

Pull request review commentyonadev/yona-server

YD-669 Pass app info all the way

+/*******************************************************************************+ * Copyright (c) 2019 Stichting Yona Foundation+ * This Source Code Form is subject to the terms of the Mozilla Public License,+ * v.2.0. If a copy of the MPL was not distributed with this file, You can+ * obtain one at https://mozilla.org/MPL/2.0/.+ *******************************************************************************/+package nu.yona.server.rest;++import java.io.IOException;++import org.springframework.http.HttpRequest;+import org.springframework.http.client.ClientHttpRequestExecution;+import org.springframework.http.client.ClientHttpRequestInterceptor;+import org.springframework.http.client.ClientHttpResponse;++public class HeadersClientInterceptor implements ClientHttpRequestInterceptor

Added a JavaDoc comment.

Bert-R

comment created time in a month

more