Skip to content

Commit

Permalink
perf($VarAndVal): synchronize codes
Browse files Browse the repository at this point in the history
ErrorController.java
Application.java
  • Loading branch information
johnnymillergh committed May 8, 2020
1 parent e94b1d1 commit e961c32
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.jmsoftware.authcenter.universal.configuration.ProjectProperty;
import com.jmsoftware.authcenter.universal.configuration.ServerConfiguration;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
Expand Down Expand Up @@ -35,10 +36,10 @@ public AuthCenterApplication(ProjectProperty projectProperty, ServerConfiguratio
}

public static void main(String[] args) {
var startInstant = Instant.now();
val startInstant = Instant.now();
SpringApplication.run(AuthCenterApplication.class, args);
var endInstant = Instant.now();
var duration = Duration.between(startInstant, endInstant);
val endInstant = Instant.now();
val duration = Duration.between(startInstant, endInstant);
log.info("🥳 Congratulations! 🎉");
log.info("🖥 {}@{} started!", projectProperty.getProjectArtifactId(), projectProperty.getVersion());
log.info("⚙️ Environment: {} ({})", projectProperty.getEnvironment(), projectProperty.getEnvironmentAlias());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController;
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver;
import org.springframework.boot.web.servlet.error.ErrorAttributes;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
Expand Down Expand Up @@ -35,8 +35,8 @@ public ErrorController(ErrorAttributes errorAttributes,

@Override
public ResponseEntity<Map<String, Object>> error(HttpServletRequest request) {
HttpStatus httpStatus = getStatus(request);
Map<String, Object> body = getErrorAttributes(request, isIncludeStackTrace(request, MediaType.ALL));
val httpStatus = getStatus(request);
val body = getErrorAttributes(request, isIncludeStackTrace(request, MediaType.ALL));
body.put("message", httpStatus.getReasonPhrase());
log.error("Captured HTTP request error. Response body = {}", body);
return new ResponseEntity<>(body, httpStatus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.jmsoftware.exercisemis.universal.configuration.ProjectProperty;
import com.jmsoftware.exercisemis.universal.configuration.ServerConfiguration;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
Expand Down Expand Up @@ -35,10 +36,10 @@ public ExerciseMisApplication(ProjectProperty projectProperty, ServerConfigurati
}

public static void main(String[] args) {
var startInstant = Instant.now();
val startInstant = Instant.now();
SpringApplication.run(ExerciseMisApplication.class, args);
var endInstant = Instant.now();
var duration = Duration.between(startInstant, endInstant);
val endInstant = Instant.now();
val duration = Duration.between(startInstant, endInstant);
log.info("🥳 Congratulations! 🎉");
log.info("🖥 {}@{} started!", projectProperty.getProjectArtifactId(), projectProperty.getVersion());
log.info("⚙️ Environment: {} ({})", projectProperty.getEnvironment(), projectProperty.getEnvironmentAlias());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController;
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver;
import org.springframework.boot.web.servlet.error.ErrorAttributes;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
Expand Down Expand Up @@ -35,8 +35,8 @@ public ErrorController(ErrorAttributes errorAttributes,

@Override
public ResponseEntity<Map<String, Object>> error(HttpServletRequest request) {
HttpStatus httpStatus = getStatus(request);
Map<String, Object> body = getErrorAttributes(request, isIncludeStackTrace(request, MediaType.ALL));
val httpStatus = getStatus(request);
val body = getErrorAttributes(request, isIncludeStackTrace(request, MediaType.ALL));
body.put("message", httpStatus.getReasonPhrase());
log.error("Captured HTTP request error. Response body = {}", body);
return new ResponseEntity<>(body, httpStatus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.jmsoftware.gateway.universal.configuration.ProjectProperty;
import com.jmsoftware.gateway.universal.configuration.ServerConfiguration;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
Expand Down Expand Up @@ -33,10 +34,10 @@ public GatewayApplication(ProjectProperty projectProperty, ServerConfiguration s
}

public static void main(String[] args) {
var startInstant = Instant.now();
val startInstant = Instant.now();
SpringApplication.run(GatewayApplication.class, args);
var endInstant = Instant.now();
var duration = Duration.between(startInstant, endInstant);
val endInstant = Instant.now();
val duration = Duration.between(startInstant, endInstant);
log.info("🥳 Congratulations! 🎉");
log.info("🖥 {}@{} started!", projectProperty.getProjectArtifactId(), projectProperty.getVersion());
log.info("⚙️ Environment: {} ({})", projectProperty.getEnvironment(), projectProperty.getEnvironmentAlias());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.jmsoftware.musclemis.universal.configuration.ProjectProperty;
import com.jmsoftware.musclemis.universal.configuration.ServerConfiguration;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
Expand Down Expand Up @@ -35,10 +36,10 @@ public MuscleMisApplication(ProjectProperty projectProperty, ServerConfiguration
}

public static void main(String[] args) {
var startInstant = Instant.now();
val startInstant = Instant.now();
SpringApplication.run(MuscleMisApplication.class, args);
var endInstant = Instant.now();
var duration = Duration.between(startInstant, endInstant);
val endInstant = Instant.now();
val duration = Duration.between(startInstant, endInstant);
log.info("🥳 Congratulations! 🎉");
log.info("🖥 {}@{} started!", projectProperty.getProjectArtifactId(), projectProperty.getVersion());
log.info("⚙️ Environment: {} ({})", projectProperty.getEnvironment(), projectProperty.getEnvironmentAlias());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController;
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver;
import org.springframework.boot.web.servlet.error.ErrorAttributes;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
Expand Down Expand Up @@ -35,8 +35,8 @@ public ErrorController(ErrorAttributes errorAttributes,

@Override
public ResponseEntity<Map<String, Object>> error(HttpServletRequest request) {
HttpStatus httpStatus = getStatus(request);
Map<String, Object> body = getErrorAttributes(request, isIncludeStackTrace(request, MediaType.ALL));
val httpStatus = getStatus(request);
val body = getErrorAttributes(request, isIncludeStackTrace(request, MediaType.ALL));
body.put("message", httpStatus.getReasonPhrase());
log.error("Captured HTTP request error. Response body = {}", body);
return new ResponseEntity<>(body, httpStatus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.jmsoftware.serviceregistry.universal.configuration.ProjectProperty;
import com.jmsoftware.serviceregistry.universal.configuration.ServerConfiguration;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
Expand Down Expand Up @@ -33,10 +34,10 @@ public ServiceRegistryApplication(ProjectProperty projectProperty, ServerConfigu
}

public static void main(String[] args) {
var startInstant = Instant.now();
val startInstant = Instant.now();
SpringApplication.run(ServiceRegistryApplication.class, args);
var endInstant = Instant.now();
var duration = Duration.between(startInstant, endInstant);
val endInstant = Instant.now();
val duration = Duration.between(startInstant, endInstant);
log.info("🥳 Congratulations! 🎉");
log.info("🖥 {}@{} started!", projectProperty.getProjectArtifactId(), projectProperty.getVersion());
log.info("⚙️ Environment: {} ({})", projectProperty.getEnvironment(), projectProperty.getEnvironmentAlias());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController;
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver;
import org.springframework.boot.web.servlet.error.ErrorAttributes;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
Expand Down Expand Up @@ -35,8 +35,8 @@ public ErrorController(ErrorAttributes errorAttributes,

@Override
public ResponseEntity<Map<String, Object>> error(HttpServletRequest request) {
HttpStatus httpStatus = getStatus(request);
Map<String, Object> body = getErrorAttributes(request, isIncludeStackTrace(request, MediaType.ALL));
val httpStatus = getStatus(request);
val body = getErrorAttributes(request, isIncludeStackTrace(request, MediaType.ALL));
body.put("message", httpStatus.getReasonPhrase());
log.error("Captured HTTP request error. Response body = {}", body);
return new ResponseEntity<>(body, httpStatus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.jmsoftware.springbootadmin.universal.configuration.ServerConfiguration;
import de.codecentric.boot.admin.server.config.EnableAdminServer;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
Expand Down Expand Up @@ -35,10 +36,10 @@ public SpringBootAdminApplication(ProjectProperty projectProperty, ServerConfigu
}

public static void main(String[] args) {
var startInstant = Instant.now();
val startInstant = Instant.now();
SpringApplication.run(SpringBootAdminApplication.class, args);
var endInstant = Instant.now();
var duration = Duration.between(startInstant, endInstant);
val endInstant = Instant.now();
val duration = Duration.between(startInstant, endInstant);
log.info("🥳 Congratulations! 🎉");
log.info("🖥 {}@{} started!", projectProperty.getProjectArtifactId(), projectProperty.getVersion());
log.info("⚙️ Environment: {} ({})", projectProperty.getEnvironment(), projectProperty.getEnvironmentAlias());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController;
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver;
import org.springframework.boot.web.servlet.error.ErrorAttributes;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
Expand Down Expand Up @@ -35,8 +35,8 @@ public ErrorController(ErrorAttributes errorAttributes,

@Override
public ResponseEntity<Map<String, Object>> error(HttpServletRequest request) {
HttpStatus httpStatus = getStatus(request);
Map<String, Object> body = getErrorAttributes(request, isIncludeStackTrace(request, MediaType.ALL));
val httpStatus = getStatus(request);
val body = getErrorAttributes(request, isIncludeStackTrace(request, MediaType.ALL));
body.put("message", httpStatus.getReasonPhrase());
log.error("Captured HTTP request error. Response body = {}", body);
return new ResponseEntity<>(body, httpStatus);
Expand Down

1 comment on commit e961c32

@johnnymillergh
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice try! Using val to make Java variables simple and powerful.

Please sign in to comment.