Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-13790

Memory leak caused by org.eclipse.yasson.internal.JsonBinding

XMLWordPrintable

      org.eclipse.yasson.internal.JsonBinding keeps a reference on an enum after the war is undeployed which results in a classloader leak.

      1- Deploy the following application:
       

      package au.com.spatiumxl.model;
      
      public class Book {
      
          public enum Status { READ, UNREAD }
      
          private String title; 
          private Book.Status status;  
      
          public Book(String title) {  
              this.title = title; 
              this.status = Book.Status.UNREAD; 
          }
      
          public String getTitle() {  
              return title; 
          }
      
          public Book.Status getStatus() { 
              return status; 
          }
      }
      

       

      package au.com.spatiumxl.ejb;
      
      [...]
      
      import au.com.spatiumxl.model.Book;
      
      @Stateless
      @LocalBean
      public class BookService {
      
          public List<Book> getBooks() {  
              List<Book> books = new ArrayList<>();
              books.add(new Book("title1"));  
              return books; 
          }
      }
      

       

      package au.com.spatiumxl.rest;
      
      [...]
      
      import au.com.spatiumxl.ejb.BookService;
      import au.com.spatiumxl.model.Book;
      
      @RequestScoped
      @Path("")public 
      class BookEndPoint {  
      
          @Inject BookService bookService;  
      
          @GET @Path("/get-books") 
          @Produces("application/json") 
          public List<Book> getBooks() {  
              return bookService.getBooks(); 
          }
      }
      

       

      2- On the browser go to: http://<host>/<context-root>/.../get-books

      3- Undeploy the war

      4- The memory analyser shows:

      java.lang.Thread
       org.jboss.modules.ModuleClassLoader
        org.jboss.modules.Module
         org.jboss.modules.LocalModuleLoader
          java.util.concurrent.ConcurrentHashMap
           java.util.concurrent.ConcurrentHashMap$Node[]
            java.util.concurrent.ConcurrentHashMap$Node
             org.jboss.modules.ModuleLoader$FutureModule
              org.jboss.modules.Module
               org.jboss.modules.ModuleClassLoader
                java.util.Vector
                 java.lang.Object[]
                  org.jboss.resteasy.plugins.providers.jsonb.AbstractJsonBindingProvider
                   org.eclipse.yasson.internal.JsonBinding
                    org.eclipse.yasson.internal.JsonbContext
                     org.eclipse.yasson.internal.MappingContext
                      java.util.concurrent.ConcurrentHashMap
                       java.util.concurrent.ConcurrentHashMap$Node[]
                        java.util.concurrent.ConcurrentHashMap$Node
                         org.eclipse.yasson.internal.model.ClassModel
                          org.eclipse.yasson.internal.model.PropertyModel[]
                           org.eclipse.yasson.internal.model.PropertyModel
                            au.com.spatiumxl.model.Book$Status
      

        1. app.zip
          3 kB
        2. WFLY-13790-0.0.1-SNAPSHOT.war
          7 kB
        3. wildfly-20.0.1.Final.PNG
          wildfly-20.0.1.Final.PNG
          290 kB
        4. wildfly-20.0.1.Final+patch.PNG
          wildfly-20.0.1.Final+patch.PNG
          333 kB

            rsearls r searls
            ahcene.kessal@spatiumxl.com.au Ahcene Kessal (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: