Uploaded image for project: 'Realm Java SDK'
  1. Realm Java SDK
  2. RJAVA-1184

I'm pulling empty data, but I've added new data.

      How frequently does the bug occur?

      Sometimes

      Description

      I'm pulling empty data, but I've added new data. It works fine on most devices but data returns blank on some devices.
      I've caught firebase null returning devices. For example Redmi Note 8 Pro, Xiaomi M2007J20CG, and some Samsung devices SM-A336E, SM-J415F...

      Stacktrace & log output

      Unable to find source-code formatter for language: shell. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      no error.
      

      Can you reproduce the bug?

      Sometimes

      Reproduction Steps

      My Realm Class;

      public class LocalRealmDB {
      public static final String TAG = LocalRealmDB.class.getName();

      public static LocalRealmDB getInstance() {
          return new LocalRealmDB();
      }
      
      //public final int SCHEMA_V_PREV = 0;// previous schema version
      public final int SCHEMA_V_NOW = 0;// change schema version if any change happened in schema
      
      private RealmConfiguration configuration;
      private Realm realm;
      
      private void initRealConfig() {
          try {
              Realm.init(Application.getInstance());
              if (configuration == null) {
                  configuration = new RealmConfiguration.Builder()
                          .schemaVersion(SCHEMA_V_NOW)
                          .name(Parameters.Config.LOCAL_DATABASE_REALM_NAME)
                          .allowWritesOnUiThread(true)
                          .allowQueriesOnUiThread(true)
                          .build();//.migration(new CustomRealmMigrations())//.deleteRealmIfMigrationNeeded()
                  Realm.setDefaultConfiguration(configuration);
              }
          } catch (Exception ex) {
              Logger.error(TAG, ex.getMessage());
          }
      }
      
      private Realm getRealm() {
          initRealConfig();
          if (realm == null) {
              realm = Realm.getDefaultInstance();
          }
          return realm;
      }
      
      private void close() {
          //Yeni bir şemeya geçilecekse kapatılır.
          getRealm().close();
          realm = null;
      }
      
      public <T extends RealmObject> void saveData(T dataModel, OnResultListenerAdapter<Boolean> listener) {
          getRealm().executeTransactionAsync(realm -> {
              LogUtil.e("saveData insertOrUpdate dataModel");
              realm.insertOrUpdate(dataModel);
          }, () -> {
              LogUtil.e("saveData onSuccess");
              listener.onSuccess("");
          }, error -> {
              LogUtil.e("saveData error: " + error.getMessage());
              listener.onFail("error: " + error.getMessage());
          });
      }
      
      public <T extends RealmObject> void saveDataList(List<T> dataList, OnResultListenerAdapter<String> listener) {
          getRealm().executeTransactionAsync(realm -> {
              //Log.e("RED_LOG", "realm");
              realm.insertOrUpdate(dataList);
          }, () -> {
              LogUtil.e("onSuccess");
              listener.onSuccess("");
              //Log.e("RED_LOG", "success");
          }, error -> {
              //Log.e("RED_LOG", "onError");
              LogUtil.e("error: " + error.getMessage());
              listener.onFail("Save Data List: " + error.getMessage());
          });
      }
      
      public <E extends RealmObject> List<E> getDataList(Class<E> clazz) {
          LogUtil.e("getDataList");
          RealmResults<E> models = getRealm().where(clazz).findAll();
          return models;
      }
      
      public <E extends RealmObject> int getSize(Class<E> clazz) {
          LogUtil.e("getSize");
          return getRealm().where(clazz).findAll().size();
      }
      
      public boolean isEmptyData() {
          LogUtil.e("isEmptyData");
          return getRealm().isEmpty();
      }
      
      public <E extends RealmObject> E getData(Class<E> clazz) {
          LogUtil.e("getData");
          return getRealm().where(clazz).findAll().last();
      }
      
      public <E extends RealmObject> List<E> getDataListWithFieldName(Class<E> clazz, String id, String fieldName) {
          RealmResults<E> models = getRealm().where(clazz).equalTo(fieldName, id).findAll();
          return models;
      }
      
      public <E extends RealmObject> boolean isData(Class<E> clazz) {
          RealmResults<E> models = getRealm().where(clazz).findAll();
          return ControlUtil.isData(models);
      }
      
      public <E extends RealmObject> boolean isDataWithId(Class<E> clazz, String employeeId) {
          RealmResults<E> models = getRealm().where(clazz).equalTo("employeeId", employeeId).findAll();
          return !models.isEmpty();
      }
      
      public <E extends RealmObject> void deleteDataWithId(Class<E> clazz, String id) {
          LogUtil.e("deleteDataWithId");
      
          getRealm().executeTransactionAsync(transactionRealm -> {
              E model = transactionRealm.where(clazz).equalTo("id", id).findFirst();
              if (model != null) {
                  model.deleteFromRealm();
              }
          });
      }
      
      public <E extends RealmObject> void deleteAll(Class<E> clazz, OnResultListenerAdapter<String> listener) {
          LogUtil.e("deleteAll");
          getRealm().executeTransactionAsync(realm -> {
              //Delete All
              realm.where(clazz).findAll().deleteAllFromRealm();
          }, () -> {
              listener.onSuccess("");
          }, error -> {
              listener.onFail(error.getMessage());
          });
      }
      

      }

      Version

      10.13.2-transformer-api

      What Atlas App Services are you using?

      Local Database only

      Are you using encryption?

      No

      Platform OS and version(s)

      Android 9,10,11

      Build environment

      Android Studio version: Android Studio Electric Eel | 2022.1.1 Patch 2
      Android Build Tools version: 33
      Gradle version: 7.4.2

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: