Tags down


How can I automatically log use of any @Deprecated annoted method in Java?

By : user3851642
Date : October 16 2020, 11:12 AM
With these it helps If you want to log every use you will probably have to use AOP. It depends on what Frameworks you are using if there is an easy way to do this. This is how it might look like in Spring:
code :

Share : facebook icon twitter icon

Spring with AspectJ on annoted method leads 404 error

By : Moshe Landau
Date : March 29 2020, 07:55 AM
To fix the issue you can do I have the following aspect hadling all REST controllers:
code :
@Pointcut(value="execution(* com.company.app.features.*.controller.*.*(..))")
public void controller() { }

public void getMapping() { }

@Before("controller() && getMapping(object)")
public void controllerGetMapping(Object objectIfYouNeedIt) {
    // Log

Grails Redis Cache - Calling @Cacheable annoted method indirectly - how to work

By : Mohammed Rafiq
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further The caching is provided by spring. So you need to use the spring way to call methods to apply the caching:
code :
EmployeeService {
    def grailsApplication

    @Cacheable(value = "employees")
    public List<Employee> getEmployeeList() {
        return Employee.list()

    public Employee getEmployee(long id){
        return proxy.getEmployeeList().find {it.id == id}

    // using springs bean proxy ensures cacheable aspects are applied
    private getProxy() {

How can test a Spring Boot controller method annoted with @PreAuthorized(hasAnyAuthority(...))

By : user3569827
Date : March 29 2020, 07:55 AM
seems to work fine I've spent part of the day figuring out how to solve this. I ended up with a solution that I think is not so bad, and could help many.
Based on what you tried to do in your test, you can do a mockMvc to test your controller. Notice that the AuthorizationServer is not called. You stay only in your Resource server for the tests.
code :
public class AuthenticationManagerProvider {

    public TokenStore tokenStore() {
        return new InMemoryTokenStore();
@WithSecurityContext(factory = WithMockOAuth2ScopeSecurityContextFactory.class)
public @interface WithMockOAuth2Scope {

    String token() default "";

    String clientId() default "client-id";

    boolean approved() default true;

    String redirectUrl() default "";

    String[] responseTypes() default {};

    String[] scopes() default {};

    String[] resourceIds() default {};

    String[] authorities() default {};

    String username() default "username";

    String password() default "";

    String email() default "";
public class WithMockOAuth2ScopeSecurityContextFactory implements WithSecurityContextFactory<WithMockOAuth2Scope> {

    private TokenStore tokenStore;

    public SecurityContext createSecurityContext(WithMockOAuth2Scope mockOAuth2Scope) {

        OAuth2AccessToken oAuth2AccessToken = createAccessToken(mockOAuth2Scope.token());
        OAuth2Authentication oAuth2Authentication = createAuthentication(mockOAuth2Scope);
        tokenStore.storeAccessToken(oAuth2AccessToken, oAuth2Authentication);

        return SecurityContextHolder.createEmptyContext();

    private OAuth2AccessToken createAccessToken(String token) {
        return new DefaultOAuth2AccessToken(token);

    private OAuth2Authentication createAuthentication(WithMockOAuth2Scope mockOAuth2Scope) {

        OAuth2Request oauth2Request = getOauth2Request(mockOAuth2Scope);
        return new OAuth2Authentication(oauth2Request,

    private OAuth2Request getOauth2Request(WithMockOAuth2Scope mockOAuth2Scope) {
        String clientId = mockOAuth2Scope.clientId();
        boolean approved = mockOAuth2Scope.approved();
        String redirectUrl = mockOAuth2Scope.redirectUrl();
        Set<String> responseTypes = new HashSet<>(asList(mockOAuth2Scope.responseTypes()));
        Set<String> scopes = new HashSet<>(asList(mockOAuth2Scope.scopes()));
        Set<String> resourceIds = new HashSet<>(asList(mockOAuth2Scope.resourceIds()));

        Map<String, String> requestParameters = Collections.emptyMap();
        Map<String, Serializable> extensionProperties = Collections.emptyMap();
        List<GrantedAuthority> authorities = AuthorityUtils.createAuthorityList(mockOAuth2Scope.authorities());

        return new OAuth2Request(requestParameters, clientId, authorities,
                approved, scopes, resourceIds, redirectUrl, responseTypes, extensionProperties);

    private Authentication getAuthentication(WithMockOAuth2Scope mockOAuth2Scope) {
        List<GrantedAuthority> grantedAuthorities = AuthorityUtils.createAuthorityList(mockOAuth2Scope.authorities());

        String username = mockOAuth2Scope.username();
        User userPrincipal = new User(username,
                true, true, true, true, grantedAuthorities);

        HashMap<String, String> details = new HashMap<>();
        details.put("user_name", username);
        details.put("email", mockOAuth2Scope.email());

        TestingAuthenticationToken token = new TestingAuthenticationToken(userPrincipal, null, grantedAuthorities);

        return token;

class SimpleControllerTest {

    private MockMvc mockMvc;

    @WithMockOAuth2Scope(token = "123456789",
            authorities = "CAN_READ")
    public void test() throws Exception {
                .header("Authorization", "Bearer 123456789"))

Class with @Deprecated annotation means that all methods and fields automatically will be deprecated

By : Ibrahim Al Ouayed
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Is Anyone knows if the class with @Deprecated annotation means that all methods and fields automatically will be deprecated..? , No. If you do

How to fix PHP Deprecated Automatically populating $HTTP_RAW_POST_DATA is deprecated issue?

By : RunRenegade
Date : March 29 2020, 07:55 AM
help you fix your problem hello i'm getting this error in my error log: ,
how can i prevent it prints on the error log?
Related Posts Related Posts :
  • First steps developing in java applet. Directions
  • java efficient de-duplication
  • Converting sequential Java to concurrent java code
  • Java variable number or arguments for a method
  • when developing locally, does it make a difference if the context is '/' or '/appname/'?
  • Problem using JUnit4TestAdapter from eclipse plugin context
  • Robot Simulation in Java
  • what are aliases in ldap
  • Calling class methods (static) from inside a velocity view page
  • How to use Struts2 validation for conditional validation?
  • Multithreaded Java Program for Conway's game of life - contention at the border cells
  • How to handle multidimensional array?
  • Working with a giant matrix with Java
  • Fast Oracle Select [Huge Data]
  • Is cayenne good choice for my requirement?
  • Extjs with google Ajax Language Api
  • Alfresco Community on Tomcat starts very slow
  • No tests found with test runner 'JUnit 4'
  • XMLTask 1.16: Does it work with Ant so far?
  • Google App Engine JAVA: How to add more than one parameter to the Task Queue?
  • java.lang.OutOfMemoryError: Java heap space
  • Is there a way in Java or a command-line util to obtain a Kerberos ticket for a service using the native SSPI API?
  • Can I use JBoss MQ on JBoss 5? If so, how?
  • Jmockit expectations error
  • Custom message with FacesContext.getCurrentInstance().addMessage is not displayed in page (JSF)
  • Applet served by Java Web Start, resources requested to WEB Server before look in the JAR files
  • How to retrieve and display images from a database in a JSP page?
  • Invoking JCL from Java
  • log4j Rolling file appender - multi-threading issues?
  • Benefits and disadvantages of using java rmi
  • random numbers in java
  • How to set formulas in cells using Apache POI?
  • Eclipse java.lang.ClassNotFoundException: com.google.gwt.dev.About
  • java equivalent of mysql string search operator 'like'
  • Where does ResourceBundle.getBundle("ResourceFile", new Locale("us", "US")) look for the f
  • Can I generate an HPROF file at will?
  • Have you ever succeed in developing high-load web-applications with JSF?
  • Infinite While Loop in Java
  • "Path login.page does not start with a "/" character" message exception after changing java version
  • Web-application configuration outside or inside war file?
  • Swing, Passive View and Long running tasks
  • How do I find maximum number of concurrent connections that a server can handle?
  • Exception in thread "thread-4" java.lang.NullPointerException
  • Is there any difference between JME and J2ME?
  • How to send attribute from Database to dJ to make Report
  • expand Tiny url in java
  • Java Binary search
  • Java: fastest way to do random reads on huge disk file(s)
  • Java: fast disk-based hash set
  • CSV row reader in Java
  • sample code for 3d games!
  • Java to/from C++ socket communication, DataInputStream and eof, binary, encryption
  • Excessive number of touch events slows down Android app
  • Cannot convert from type object to long
  • Java consumes too much memory
  • Problem with the length of path in GCC
  • Java-lib for XML tree visualization
  • Which Data Structure? LinkedList or Any Other in Java?
  • Compilation error when instantiating a new ArrayList
  • How do I make this mouselistener only care about one object?
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org