Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8222400

When running Object Box queries, OpenJDK Runtime Environment fata error occurs

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      linux_ubuntu

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Ubuntu 18.10. OpenJDK 11

      A DESCRIPTION OF THE PROBLEM :
      Whenever I am using the Java Object Box APIs to query an Object Box database, a Runtime Environment fata error occurs.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      # A fatal error has been detected by the Java Runtime Environment:
      #
      # SIGSEGV (0xb) at pc=0x00007f365cfa1d00, pid=13984, tid=14199
      #
      # JRE version: OpenJDK Runtime Environment (11.0.1+13) (build 11.0.1+13-Ubuntu-3ubuntu3.18.10.1)
      # Java VM: OpenJDK 64-Bit Server VM (11.0.1+13-Ubuntu-3ubuntu3.18.10.1, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64)
      # Problematic frame:
      # V [libjvm.so+0x552d00]
      #
      # Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %d %P" (or dumping to /home/wesley/Documents/repo/panther/core.13984)
      #
      # An error report file with more information is saved as:
      # /home/wesley/Documents/repo/panther/hs_err_pid13984.log
      #
      # If you would like to submit a bug report, please visit:
      # http://bugreport.java.com/bugreport/crash.jsp
      #
      [WARN ] Skipped low-level close of cursor (write, TX #5 alive)
      [INFO ] Creating query #1 for PoleEntity with 1 condition(s)
      [INFO ] Finding using query #1
      [INFO ] Parameters for query #1:
      uuid ==(i) "TestUUID"
      [ERROR] Entity creation failed


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Build Object Box classes with entities annotations with relations and run unit tests querying the database.

      ACTUAL -
      Java Object Box object is not created.

      ---------- BEGIN SOURCE ----------
      import io.objectbox.annotation.*;
      import io.objectbox.relation.ToMany;

      import java.sql.ResultSet;
      import java.sql.SQLException;
      import java.util.Date;
      import java.util.logging.Level;
      import java.util.logging.Logger;

      @Entity
      public class PoleEntity {

          private static Logger logger = PhotoExceptionLogger.getLogger();

          @Id
          private long id;
          public ToMany<TriangleEntity> triangleEntities;
          @Unique
          private String uuid;
          private String databaseName;
          private int poleMasterid, photoCount;
          private Date surveyDate;

          public PoleEntity(){ }

          public PoleEntity(long id, String uuid, String databaseName, int poleMasterid, int photoCount, Date surveyDate) {
              this.id = id;
              this.uuid = uuid;
              this.databaseName = databaseName;
              this.poleMasterid = poleMasterid;
              setPhotoCount(photoCount);
              setSurveyDate(this.surveyDate = surveyDate);
              logger.log(Level.INFO, "Pole Entity created. " + PrintPoleEntityDetails());
          }

          public PoleEntity(ResultSet legacyDbResultSet) throws SQLException {
              this.uuid = legacyDbResultSet.getString("uuidfield");
              this.databaseName = legacyDbResultSet.getString("database_name");
              this.poleMasterid = legacyDbResultSet.getInt("synthetic_id");
              setPhotoCountFromResultSet(legacyDbResultSet);
              setSurveyDate(legacyDbResultSet.getDate("surveyDate"));
              logger.log(Level.INFO, "Pole Entity created. " + PrintPoleEntityDetails());
          }

          public String PrintPoleEntityDetails(){
              String poleEntityDetails = "Pole details - ID: " + this.id + " Database Name: " + this.databaseName + " Pole Master ID: " +
                      this.poleMasterid + " UUID: " + this.uuid + " Photo Count: " + this.photoCount;
              return poleEntityDetails;
          }

          private void setPhotoCountFromResultSet(ResultSet resultSet) {
              try {
                  this.photoCount = resultSet.getInt("photoCount");
                  if (photoCount <= 0){
                      logger.log(Level.SEVERE,
                              "Photo count was 0 or less than 0. Pole entities for the Photo Exception report must be greater than 0 and not null");
                      throw new IllegalArgumentException();
                  }
              } catch (NullPointerException | SQLException e) {
                  logger.log(Level.SEVERE,
                          "Photo count was null. Pole entities for the Photo Exception report must be greater than 0 and not null");
                  throw new IllegalArgumentException();
              }
          }

          public long getId() {
              return id;
          }

          public String getUuid() {
              return uuid;
          }

          public String getDatabaseName() {
              return databaseName;
          }

          public int getPoleMasterid() {
              return poleMasterid;
          }

          public int getPhotoCount() {
              return photoCount;
          }

          public void setId(long id) {
              this.id = id;
          }

          public void setUuid(String uuid) {
              this.uuid = uuid;
          }

          public void setDatabaseName(String databaseName) {
              this.databaseName = databaseName;
          }

          public void setPhotoCount(int photoCount) {
              if (photoCount <= 0){
                  logger.log(Level.SEVERE,
                          "Photo count was 0 or less than 0. Pole entities for the Photo Exception report must be greater than 0 and not null");
                  throw new IllegalArgumentException();
              }
              else {
                  this.photoCount = photoCount;
              }
          }

          public void setPoleMasterid(int poleMasterid) {
              this.poleMasterid = poleMasterid;
          }

          public Date getSurveyDate() {
              return surveyDate;
          }

          public void setSurveyDate(Date surveyDate) {
              if (surveyDate == null){
                  logger.log(Level.SEVERE,
                          "Survey date was null. Pole entities for the Photo Exception report must not have a null survey date.");
                  throw new NullPointerException();
              }
              else {
                  this.surveyDate = surveyDate;
              }
          }
      }

      import io.objectbox.annotation.*;
      import io.objectbox.relation.ToOne;

      import java.sql.ResultSet;
      import java.sql.SQLException;
      import java.util.Date;
      import java.util.logging.Level;
      import java.util.logging.Logger;

      @Entity
      public class TriangleEntity {

          private static Logger logger = PhotoExceptionLogger.getLogger();

          @Id
          public long id;

          public long poleEntityId;
          public ToOne<PoleEntity> poleEntity;

          @Index
          private String uuid;

          @Unique
          private String googleFileId;

          @Unique
          private int triangleMasterId;

          private String photoName;
          private int systemSize;
          private boolean assetUploadConfirmed, photoFound;
          private Date systemCreateDate;

          public TriangleEntity() { }

          public TriangleEntity(ResultSet legacyDbResultSet) throws SQLException {
              this.uuid = legacyDbResultSet.getString("uuid_external");
              this.googleFileId = legacyDbResultSet.getString("google_file_id");
              this.photoName = legacyDbResultSet.getString("name");
              this.triangleMasterId = legacyDbResultSet.getInt("id");
              this.systemSize = legacyDbResultSet.getInt("system_size");
              this.assetUploadConfirmed = legacyDbResultSet.getBoolean("asset_upload_confirmed");
              this.systemCreateDate = legacyDbResultSet.getDate("system_create_date");
              logger.log(Level.INFO, "Triangle Entity created. " + PrintTriangleEntityBasicDetails());
              this.photoFound = false;
          }

          public TriangleEntity(long id, long poleEntityId, String uuid, String googleFileId, int triangleMasterId, String photoName, int systemSize, boolean assetUploadConfirmed, boolean photoFound, Date systemCreateDate) {
              this.id = id;
              this.poleEntityId = poleEntityId;
              this.uuid = uuid;
              this.googleFileId = googleFileId;
              this.triangleMasterId = triangleMasterId;
              this.photoName = photoName;
              this.systemSize = systemSize;
              this.assetUploadConfirmed = assetUploadConfirmed;
              this.photoFound = photoFound;
              this.systemCreateDate = systemCreateDate;
              logger.log(Level.INFO, "Triangle Entity created. " + PrintTriangleEntityFullDetails());
          }

          public String PrintTriangleEntityBasicDetails() {
              String triangleEntityDetails = "Triangle Entity Details - Triangle Master ID: " + this.triangleMasterId +
                      " UUID: " + this.uuid + " Google File ID: " + this.googleFileId + " Asset Upload Confirmed?: " +
                      assetUploadConfirmed + " System Create Date: " + systemCreateDate + " Size: " + this.systemSize;
              return triangleEntityDetails;
          }

          public String PrintTriangleEntityFullDetails(){
              String triangleEntityDetails = "Triangle Entity Details - ID: " + this.id + " Related Pole Entity ID: " +
                      this.poleEntityId + " Triangle Master ID: " + this.triangleMasterId +
                      " UUID: " + this.uuid + " Google File ID: " + this.googleFileId + " Asset Upload Confirmed?: " +
                      assetUploadConfirmed + " System Create Date: " + systemCreateDate + " Size: " + this.systemSize +
                      " Related Pole Entity ID: " + poleEntityId + " Photo Found: " + photoFound;
              return triangleEntityDetails;
          }

          public String getUuid() {
              return uuid;
          }

          public String getGoogleFileId() {
              return googleFileId;
          }

          public String getPhotoName() {
              return photoName;
          }

          public int getTriangleMasterId() {
              return triangleMasterId;
          }

          public boolean isAssetUploadConfirmed() {
              return assetUploadConfirmed;
          }

          public boolean isPhotoFound() {
              return photoFound;
          }

          public Date getSystemCreateDate() {
              return systemCreateDate;
          }

          public long getId() {
              return id;
          }

          public int getSystemSize(){
              return systemSize;
          }

          public void setId(long id) {
              this.id = id;
          }

          public void setUuid(String uuid) {
              this.uuid = uuid;
          }

          public void setPhotoFound(boolean photoFound) {
              this.photoFound = photoFound;
          }

          public void setGoogleFileId(String googleFileId) {
              this.googleFileId = googleFileId;
          }

          public void setPhotoName(String photoName) {
              this.photoName = photoName;
          }

          public void setAssetUploadConfirmed(boolean assetUploadConfirmed) {
              this.assetUploadConfirmed = assetUploadConfirmed;
          }

          public void setSystemCreateDate(Date systemCreateDate) {
              this.systemCreateDate = systemCreateDate;
          }

          public void setSystemSize(int systemSize) {
              this.systemSize = systemSize;
          }

          public void setTriangleMasterId(int triangleMasterId) {
              this.triangleMasterId = triangleMasterId;
          }
      }

      import io.objectbox.Box;
      import io.objectbox.BoxStore;
      import io.objectbox.DebugFlags;
      import io.objectbox.generator.model.Query;
      import io.objectbox.query.QueryBuilder;
      import org.junit.AfterClass;
      import org.junit.BeforeClass;
      import org.junit.Test;

      import java.io.File;
      import java.util.Date;
      import java.util.List;

      public class ObjectBoxTEST {


          private static File boxStoreDir;
          private static BoxStore boxStore;
          private static Box<PoleEntity> poleEntityBox;
          private static Box<TriangleEntity> triangleEntityBox;

          @BeforeClass
          public static void ObjectBox_PutPoleEntity() throws Exception {
              File TEST_DIRECTORY = new File("build/object-box-test");
              boxStoreDir = TEST_DIRECTORY;
              boxStoreDir.mkdir();
              boxStore = MyObjectBox.builder().directory(boxStoreDir).debugFlags(DebugFlags.LOG_QUERIES | DebugFlags.LOG_QUERY_PARAMETERS).build();
              poleEntityBox = boxStore.boxFor(PoleEntity.class);
              triangleEntityBox = boxStore.boxFor(TriangleEntity.class);

              PoleEntity pe1 = new PoleEntity();
              pe1.setDatabaseName("TestDatabaseName");
              pe1.setPhotoCount(5);
              pe1.setPoleMasterid(325);
              pe1.setUuid("TestUUID");
              poleEntityBox.put(pe1);

              PoleEntity pe2 = new PoleEntity();
              pe2.setDatabaseName("TestDatabaseName");
              pe2.setPhotoCount(1);
              pe2.setPoleMasterid(125);
              pe2.setUuid("TestUUID1");

              TriangleEntity te = new TriangleEntity();
              te.setTriangleMasterId(500);
              te.setPhotoName("TestName");
              te.setUuid("TestUUID1");
              te.setAssetUploadConfirmed(true);
              te.setPhotoFound(true);
              te.setGoogleFileId("TestGFID");
              te.setSystemSize(123456);
              te.setSystemCreateDate(new Date());

              te.poleEntity.setTarget(pe2);
              pe2.triangleEntities.add(te);

              boxStore.boxFor(TriangleEntity.class).put(te);
              boxStore.boxFor(PoleEntity.class).put(pe2);

          }



          @Test
          public void ObjectBox_VerifyUuid() {
              QueryBuilder<PoleEntity> builder = poleEntityBox.query();
              builder.equal(PoleEntity_.uuid, "TestUUID");
              List<PoleEntity> poleEntities = builder.build().find();
              PoleEntity poleEntity = poleEntities.get(0);
              assert poleEntity.getUuid().equals("TestUUID");
          }

          @Test
          public void ObjectBox_VerifyPoleMasterId() {
              QueryBuilder<PoleEntity> builder = poleEntityBox.query();
              builder.equal(PoleEntity_.uuid, "TestUUID");
              List<PoleEntity> poleEntities = builder.build().find();
              PoleEntity poleEntity = poleEntities.get(0);
              assert poleEntity.getPoleMasterid() == 325;
          }

          @Test
          public void ObjectBox_VerifyDatabaseName() {
              QueryBuilder<PoleEntity> builder = poleEntityBox.query();
              builder.equal(PoleEntity_.uuid, "TestUUID");
              List<PoleEntity> poleEntities = builder.build().find();
              PoleEntity poleEntity = poleEntities.get(0);
              assert poleEntity.getDatabaseName().equals("TestDatabaseName");
          }

          @Test
          public void ObjectBox_VerifyTriangleEntityPut() {
              TriangleEntity triangleEntity = triangleEntityBox.query().build().findFirst();
              assert triangleEntity != null;
          }

          @Test
          public void ObjectBox_VerifyPoleEntityPut() {
              PoleEntity poleEntity = poleEntityBox.query().build().findFirst();
              assert poleEntity != null;
          }

          @Test
          public void ObjectBox_VerifyTriangleEntityLinkedToPoleEntity() {
              TriangleEntity triangleEntity = triangleEntityBox.query().build().findFirst();
              assert triangleEntity.poleEntityId != 0;
          }

          @Test
          public void ObjectBox_VerifyLinkedPoleEntityUuid() {
              TriangleEntity triangleEntity = triangleEntityBox.query().build().findFirst();
              PoleEntity poleEntity = triangleEntity.poleEntity.getTarget();
              assert poleEntity.getUuid().equals("TestUUID1");
          }

          @AfterClass
          public static void ObjectBox_DeleteDatabaseData() {
              if (boxStore != null){
                  boxStore.close();
                  boxStore.deleteAllFiles();
              }
          }


      }



      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              fmatte Fairoz Matte
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: