title: java.lang.NullPointerException: Cannot invoke "service" because "this.contentService" is null
body: <p>Hey When i am making a get request to my spring microservice i am recieving this error and same from my other microservices as well i am sorry i am new with microservices and spring
  i think its something related to my jwt filter can someone help me with this</p>
  <pre><code>2021-10-21 21:10:31.006 ERROR 10252 --- [nio-8082-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException: Cannot invoke &quot;com.bloggie.contentservice.service.contracts.ContentService.getAccessibleContent()&quot; because &quot;this.contentService&quot; is null] with root cause
  
  java.lang.NullPointerException: Cannot invoke &quot;com.bloggie.contentservice.service.contracts.ContentService.getAccessibleContent()&quot; because &quot;this.contentService&quot; is null
      at com.bloggie.contentservice.controller.ContentController.getPublicContent(ContentController.kt:27) ~[classes/:na]
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[na:na]
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
      at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
      at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.10.jar:5.3.10]
      at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.10.jar:5.3.10]
      at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.10.jar:5.3.10]
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.10.jar:5.3.10]
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.10.jar:5.3.10]
      at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.10.jar:5.3.10]
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067) ~[spring-webmvc-5.3.10.jar:5.3.10]
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.10.jar:5.3.10]
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.10.jar:5.3.10]
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.3.10.jar:5.3.10]
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:655) ~[tomcat-embed-core-9.0.53.jar:4.0.FR]
      at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.10.jar:5.3.10]
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) ~[tomcat-embed-core-9.0.53.jar:4.0.FR]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.53.jar:9.0.53]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) ~[spring-web-5.3.10.jar:5.3.10]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:327) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:81) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:121) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:115) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:126) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:81) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:105) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:149) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
      at com.bloggie.contentservice.configurations.filters.JwtRequestFilter.doFilterInternal(JwtRequestFilter.kt:41) ~[classes/:na]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.10.jar:5.3.10]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.10.jar:5.3.10]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:110) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:80) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.10.jar:5.3.10]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:211) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:183) ~[spring-security-web-5.5.2.jar:5.5.2]
      at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) ~[spring-web-5.3.10.jar:5.3.10]
      at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) ~[spring-web-5.3.10.jar:5.3.10]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.10.jar:5.3.10]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.10.jar:5.3.10]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.10.jar:5.3.10]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.10.jar:5.3.10]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.10.jar:5.3.10]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.10.jar:5.3.10]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1726) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.53.jar:9.0.53]
      at java.base/java.lang.Thread.run(Thread.java:831) ~[na:na]
  </code></pre>
  <p>JWT Request filter</p>
  <pre><code>package com.bloggie.contentservice.configurations.filters
  
  import com.axisbank.server.utils.JwtUtil
  import com.bloggie.contentservice.service.DefaultUserDetailService
  import org.springframework.security.authentication.UsernamePasswordAuthenticationToken
  import org.springframework.security.core.context.SecurityContextHolder
  import org.springframework.security.web.authentication.WebAuthenticationDetailsSource
  import org.springframework.stereotype.Component
  import org.springframework.web.filter.OncePerRequestFilter
  import javax.servlet.FilterChain
  import javax.servlet.http.HttpServletRequest
  import javax.servlet.http.HttpServletResponse
  
  @Component
  class JwtRequestFilter(
      private val defaultUserDetailService: DefaultUserDetailService,
  ) : OncePerRequestFilter() {
      override fun doFilterInternal(request: HttpServletRequest, response: HttpServletResponse, chain: FilterChain) {
          val authorizationHeader = request.getHeader(&quot;Authorization&quot;)
  
          if (authorizationHeader != null &amp;&amp; authorizationHeader.startsWith(&quot;Bearer &quot;)) {
              println(authorizationHeader)
              val jwt = authorizationHeader.substring(7)
  
              val userName = JwtUtil.extractUsername(jwt)
              val claims = JwtUtil.extractAllClaims(jwt)
  
              if (claims[&quot;authorities&quot;] != null &amp;&amp; SecurityContextHolder.getContext().authentication == null) {
                  val userDetails = defaultUserDetailService.loadUserByUsername(userName)
                  println(userDetails.authorities)
                  if (JwtUtil.validateToken(jwt, userDetails)) {
                      val userNamePasswordAuthenticationToken = UsernamePasswordAuthenticationToken(
                          userDetails, null, userDetails.authorities
                      )
                      userNamePasswordAuthenticationToken
                          .details = WebAuthenticationDetailsSource().buildDetails(request)
                      SecurityContextHolder.getContext().authentication = userNamePasswordAuthenticationToken
                  }
              }
          }
          chain.doFilter(request, response)
      }
  }
  </code></pre>
  <p><strong>Edited</strong></p>
  <p>Content Service</p>
  <pre><code>package com.bloggie.contentservice.service
  
  import com.bloggie.contentservice.dto.Messages
  import com.bloggie.contentservice.dto.blog.Blog
  import com.bloggie.contentservice.entities.BlogAccessStatus
  import com.bloggie.contentservice.entities.BlogCategory
  import com.bloggie.contentservice.entities.BlogCategory.*
  import com.bloggie.contentservice.service.contracts.ContentService
  import com.bloggie.contentservice.service.contracts.PublicProfileService
  import org.springframework.security.core.userdetails.UserDetails
  import org.springframework.stereotype.Service
  
  @Service
  class DefaultContentService(
      private val publicProfileService: PublicProfileService,
      private val requestService: RequestService
  ) : ContentService {
      override fun getSearchedContent(personalizedSearchRequest: Messages.PersonalizedSearchRequest): MutableList&lt;Blog&gt; {
          val blogIndexes = requestService.getAllBlogIndexes()
          var blogList = mutableListOf&lt;Blog&gt;()
          val searchString = personalizedSearchRequest.searchString
          val searchedCategory = personalizedSearchRequest.category
  
          for (blogIndex in blogIndexes) {
              val blog = requestService.getBlogById(blogIndex.blogId)
  
              when (searchedCategory) {
                  ALL -&gt; if (blog.blogTitle.contains(searchString) || blog.data.contains(searchString)) run {
                      blogList.add(blog)
                  }
                  TECHNICAL -&gt; blogList = addAccordingToCategoryAndSearchString(blog, searchString, blogList, TECHNICAL)
  
                  LIFESTYLE -&gt; blogList = addAccordingToCategoryAndSearchString(blog, searchString, blogList, LIFESTYLE)
  
                  GAMING -&gt; blogList = addAccordingToCategoryAndSearchString(blog, searchString, blogList, GAMING)
  
                  ENTERTAINMENT -&gt; blogList = addAccordingToCategoryAndSearchString(blog, searchString, blogList, ENTERTAINMENT)
  
                  MOVIES -&gt; blogList = addAccordingToCategoryAndSearchString(blog, searchString, blogList, MOVIES)
              }
          }
          return blogList
      }
  
      private fun addAccordingToCategoryAndSearchString(
          blog: Blog,
          searchString: String,
          blogList: MutableList&lt;Blog&gt;,
          category: BlogCategory
      ): MutableList&lt;Blog&gt; {
          if (blog.blogCategory == category &amp;&amp;
              (blog.blogTitle.contains(searchString) ||
                      blog.data.contains(searchString))
          ) {
              blogList.add(blog)
          }
          return blogList
      }
  
      override fun getAccessibleContent(): MutableList&lt;Blog&gt; {
          val blogList = mutableListOf&lt;Blog&gt;()
          val blogIndexes = requestService.getAllBlogIndexes()
  
          val principal: UserDetails
          var username = &quot;&quot;
          if(requestService.userAuthentication != null) {
              principal = requestService.userAuthentication.principal as UserDetails
              username = principal.username
          }
  
          for (blogIndex in blogIndexes) {
              val blog = requestService.getBlogById(blogIndex.blogId)
              when {
                  !requestService.isUserAuthenticated || blog.blogAccessStatus == BlogAccessStatus.PUBLIC -&gt; {
                      blogList.add(blog)
                  }
                  requestService.isUserAuthenticated &amp;&amp; blog.blogAccessStatus == BlogAccessStatus.PRIVATE &amp;&amp; username == blog.owner.userName -&gt; {
                      blogList.add(blog)
                  }
                  blog.blogAccessStatus == BlogAccessStatus.PRIVATE &amp;&amp; blog.sharedWith.contains(
                      publicProfileService.createPublicProfileByUsername(
                          blog.owner.userName
                      )
                  ) -&gt; {
                      blogList.add(blog)
                  }
              }
          }
          return blogList
      }
  
      override fun getPrivateContent(): MutableList&lt;Blog&gt; {
          val blogIndexes = requestService.getAllBlogIndexes()
          val blogList = mutableListOf&lt;Blog&gt;()
          val principal = requestService.userAuthentication.principal as UserDetails
          val username = principal.username
  
          for (blogIndex in blogIndexes) {
              val blog = requestService.getBlogById(blogIndex.blogId)
  
              if ((blog.blogAccessStatus == BlogAccessStatus.PRIVATE &amp;&amp; blog.owner.userName == username) ||
                  (blog.sharedWith.contains(publicProfileService.createPublicProfileByUsername(username)))
              ) {
                  blogList.add(blog)
              }
          }
  
          return blogList
      }
  }
  </code></pre>
  <p>please let me know if anything else is required</p>
  <p>Conroller</p>
  <pre><code>package com.bloggie.contentservice.controller
  
  import com.bloggie.contentservice.dto.Messages
  import com.bloggie.contentservice.dto.blog.Blog
  import com.bloggie.contentservice.service.contracts.ContentService
  import org.springframework.http.ResponseEntity
  import org.springframework.validation.annotation.Validated
  import org.springframework.web.bind.annotation.GetMapping
  import org.springframework.web.bind.annotation.PostMapping
  import org.springframework.web.bind.annotation.RequestBody
  import org.springframework.web.bind.annotation.RestController
  
  @RestController
  @Validated
  open class ContentController(
      val contentService: ContentService
  ) {
      @PostMapping(&quot;/search&quot;)
      fun getSearchedContent(
          @RequestBody personalizedSearchRequest: Messages.PersonalizedSearchRequest
      ): ResponseEntity&lt;MutableList&lt;Blog&gt;&gt; {
          return ResponseEntity.ok(contentService.getSearchedContent(personalizedSearchRequest))
      }
  
      @GetMapping
      fun getPublicContent(): ResponseEntity&lt;MutableList&lt;Blog&gt;&gt; {
          return ResponseEntity.ok(contentService.getAccessibleContent())
      }
  
      @GetMapping(&quot;/private&quot;)
      fun getPrivateContent(): ResponseEntity&lt;MutableList&lt;Blog&gt;&gt; {
          return ResponseEntity.ok(contentService.getPrivateContent())
      }
  }
  </code></pre>