Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master #11

Merged
merged 27 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e8e881a
Fix regression with partitioned tables in PostgreSQL
chunlinyao May 23, 2023
df07e4e
Merge pull request #585 from chunlinyao/fix-pgjdbc-regression-partiti…
jonesde Jul 24, 2023
d93b4ee
Add subscreensItem.menuInclude to menu data (#600)
Jul 26, 2023
86c3e0c
Docker-Image-Pull Feature (#553)
rohitpawar2811 Jul 26, 2023
fba8006
Library updates, including Jetty 10.0.13 to 10.015 which had reported…
jonesde Jul 26, 2023
e9e7a13
In ScreenRenderImpl change addFormFieldValue() and related methods to…
jonesde Jul 29, 2023
2e08c17
In root build.gradle change gitStatusAll task to be more tolerant of …
jonesde Aug 4, 2023
753e67f
Add text-area.@autogrow attribute, supported only in qvt for now
jonesde Sep 4, 2023
a619a06
Update various libraries including Groovy to 3.0.19 (which has some m…
jonesde Sep 5, 2023
aab56c9
In build.gradle gitStatusAll task also handle upstream remotes with n…
jonesde Sep 5, 2023
df5e4cc
Currency (#614)
jenshp Sep 12, 2023
7a8739b
Add and Handle Hmac Sha256 with timestamp
acetousk Oct 6, 2023
41970a7
Merge pull request #617 from coarchy/hmac-sha256-timestamp2
jonesde Oct 7, 2023
04b535b
A couple of minor bug fixes in the EntityAutoServiceRunner and Contex…
aabiabdallah Oct 13, 2023
648ae4d
Allow for 10 second threshold in nowTimestamp
acetousk Oct 17, 2023
2f7923e
Merge pull request #619 from moqui/allow-now-threshold
jonesde Oct 17, 2023
49ad11b
In L10nFacadeImpl.formatCurrency() use disableAuthz() for entity find…
jonesde Oct 17, 2023
432df20
In addons.xml, added new moqui-sso component.
aabiabdallah Oct 18, 2023
ef129ed
Merge pull request #620 from moqui/sso-component
jonesde Oct 18, 2023
36fbdca
Merge branch 'moqui:master' into master
dixitdeepak Nov 6, 2023
d82db61
Add AutoCloseable extension to EntityListIterator for use with try wi…
jonesde Nov 15, 2023
746d85c
BugFix EntityListIterator not closed in NotificationMessageImpl#getNo…
chunlinyao Nov 29, 2023
e7d8b9a
Merge branch 'moqui:master' into master
dixitdeepak Nov 29, 2023
e6135fa
Implemented withCloseable/try-with-resources where needed in the code…
dixitdeepak Nov 29, 2023
b4287f1
Change EntityDataWriterImpl to use groovy CompileStatic, without this…
jonesde Nov 29, 2023
10abd87
Merge branch 'moqui:master' into master
dixitdeepak Dec 3, 2023
5f605d0
Merge branch 'main' into master
dixitdeepak Dec 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions framework/service/org/moqui/impl/EntitySyncServices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,10 @@ along with this software (see the LICENSE.md file). If not, see
// ec.logger.warn("=========== get#EntitySyncData entityName=${entryMap.entityName} count=${currentCount} find=${find}")

if (currentCount > 0) {
EntityListIterator resultEli = find.iterator()
try {
find.iterator().withCloseable ({resultEli ->
int levels = entryMap.dependents ? 2 : 0
resultEli.writeXmlText((Writer) entityWriter, null, levels)
} finally {
resultEli.close()
}
})
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ import org.moqui.BaseArtifactException
import org.moqui.Moqui
import org.moqui.context.ExecutionContext
import org.moqui.context.NotificationMessage
import org.moqui.context.NotificationMessage.NotificationType
import org.moqui.entity.EntityFacade
import org.moqui.entity.EntityList
import org.moqui.entity.EntityListIterator
import org.moqui.entity.EntityValue
import org.slf4j.Logger
import org.slf4j.LoggerFactory
Expand Down Expand Up @@ -93,20 +91,17 @@ class NotificationMessageImpl implements NotificationMessage, Externalizable {

// notify by group, skipping users already notified
if (userGroupId) {
EntityListIterator eli = ef.find("moqui.security.UserGroupMember")
ef.find("moqui.security.UserGroupMember")
.conditionDate("fromDate", "thruDate", new Timestamp(System.currentTimeMillis()))
.condition("userGroupId", userGroupId).disableAuthz().iterator()
try {
.condition("userGroupId", userGroupId).disableAuthz().iterator().withCloseable ({eli ->
EntityValue nextValue
while ((nextValue = (EntityValue) eli.next()) != null) {
String userId = (String) nextValue.userId
if (checkedUserIds.contains(userId)) continue
checkedUserIds.add(userId)
if (checkUserNotify(userId, ef)) notifyUserIds.add(userId)
}
} finally {
eli.close();
}
})
}

// add all users subscribed to all messages on the topic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,7 @@ class EntityDataDocument {
// do the one big query
String lastDocId = null
int docCount = 0
EntityListIterator mainEli = mainFind.iterator()
try {
try (EntityListIterator mainEli = mainFind.iterator()) {
logger.info("Feed dataDocumentId ${dataDocumentId} query complete (cursor opened) in ${System.currentTimeMillis() - startTimeMillis}ms")
EntityValue ev
while ((ev = (EntityValue) mainEli.next()) != null) {
Expand Down Expand Up @@ -345,7 +344,6 @@ class EntityDataDocument {
efi.ecfi.serviceFacade.sync().name(feedReceiveServiceName).parameter("documentList", documentMapList).call()
}
} finally {
mainEli.close()
logger.info("Feed dataDocumentId ${dataDocumentId} feed complete and cursor closed in ${System.currentTimeMillis() - startTimeMillis}ms")
}

Expand All @@ -366,16 +364,14 @@ class EntityDataDocument {
ArrayList<Map> documentMapList = ddi.hasAllPrimaryPks ? null : new ArrayList<Map>()

// do the one big query
EntityListIterator mainEli = mainFind.iterator()
try {

mainFind.iterator().withCloseable ({mainEli->
EntityValue ev
while ((ev = (EntityValue) mainEli.next()) != null) {
// logger.warn("=========== DataDocument query result for ${dataDocumentId}: ${ev}")
mergeValueToDocMap(ev, ddi, documentMapMap, documentMapList, docTsString)
}
} finally {
mainEli.close()
}
})

// make the actual list and return it
if (ddi.hasAllPrimaryPks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.moqui.impl.entity

import groovy.json.JsonBuilder
import groovy.transform.CompileStatic
import org.moqui.entity.EntityValue
import org.moqui.util.ObjectUtilities

Expand All @@ -35,6 +36,7 @@ import java.time.format.DateTimeFormatter
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream

@CompileStatic
class EntityDataWriterImpl implements EntityDataWriter {
private final static Logger logger = LoggerFactory.getLogger(EntityDataWriterImpl.class)

Expand Down Expand Up @@ -170,9 +172,9 @@ class EntityDataWriterImpl implements EntityDataWriter {
EntityDefinition ed = efi.getEntityDefinition(en)
boolean useMaster = masterName != null && masterName.length() > 0 && ed.getMasterDefinition(masterName) != null
EntityFind ef = makeEntityFind(en)
EntityListIterator eli = ef.iterator()

try {

try (EntityListIterator eli = ef.iterator()) {
if (!eli.hasNext()) continue

String filename = path + '/' + en + '.' + fileType.name().toLowerCase()
Expand Down Expand Up @@ -200,8 +202,6 @@ class EntityDataWriterImpl implements EntityDataWriter {
} finally {
pw.close()
}
} finally {
eli.close()
}
}
} catch (Throwable t) {
Expand Down Expand Up @@ -248,8 +248,7 @@ class EntityDataWriterImpl implements EntityDataWriter {
EntityDefinition ed = efi.getEntityDefinition(en)
boolean useMaster = masterName != null && masterName.length() > 0 && ed.getMasterDefinition(masterName) != null
EntityFind ef = makeEntityFind(en)
EntityListIterator eli = ef.iterator()
try {
try (EntityListIterator eli = ef.iterator()) {
if (!eli.hasNext()) continue

String filenameBase = tableColumnNames ? ed.getTableName() : en
Expand All @@ -274,8 +273,6 @@ class EntityDataWriterImpl implements EntityDataWriter {
} finally {
out.closeEntry()
}
} finally {
eli.close()
}
}
} finally {
Expand All @@ -289,7 +286,13 @@ class EntityDataWriterImpl implements EntityDataWriter {
int writer(Writer writer) {
if (dependentLevels > 0) efi.createAllAutoReverseManyRelationships()

LinkedHashSet<String> activeEntityNames = skipEntityNames.size() > 0 ? entityNames - skipEntityNames : entityNames
LinkedHashSet<String> activeEntityNames
if (skipEntityNames.size() == 0) {
activeEntityNames = entityNames
} else {
activeEntityNames = new LinkedHashSet<>(entityNames)
activeEntityNames.removeAll(skipEntityNames)
}
EntityDefinition singleEd = null
if (activeEntityNames.size() == 1) singleEd = efi.getEntityDefinition(activeEntityNames.first())

Expand All @@ -305,15 +308,11 @@ class EntityDataWriterImpl implements EntityDataWriter {
for (String en in activeEntityNames) {
EntityDefinition ed = efi.getEntityDefinition(en)
boolean useMaster = masterName != null && masterName.length() > 0 && ed.getMasterDefinition(masterName) != null
EntityFind ef = makeEntityFind(en)
EntityListIterator eli = ef.iterator()
try {
try (EntityListIterator eli = makeEntityFind(en).iterator()) {
EntityValue ev
while ((ev = eli.next()) != null) {
valuesWritten+= writeValue(ev, writer, useMaster)
}
} finally {
eli.close()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1149,19 +1149,18 @@ abstract class EntityFindBase implements EntityFind {
}

// call the abstract method
EntityListIterator eli
try { eli = iteratorExtended(queryWhereCondition, havingCondition, orderByExpanded, fieldInfoArray, fieldOptionsArray) }
try (EntityListIterator eli = iteratorExtended(queryWhereCondition, havingCondition, orderByExpanded, fieldInfoArray, fieldOptionsArray)) {
MNode databaseNode = this.efi.getDatabaseNode(ed.getEntityGroupName())
if (limit != null && databaseNode != null && "cursor".equals(databaseNode.attribute("offset-style"))) {
el = (EntityListImpl) eli.getPartialList(offset != null ? offset : 0, limit, false)
} else {
el = (EntityListImpl) eli.getCompleteList(false);
}
}
catch (SQLException e) { throw new EntitySqlException(makeErrorMsg("Error finding list of", LIST_ERROR, queryWhereCondition, ed, ec), e) }
catch (ArtifactAuthorizationException e) { throw e }
catch (Exception e) { throw new EntityException(makeErrorMsg("Error finding list of", LIST_ERROR, queryWhereCondition, ed, ec), e) }

MNode databaseNode = this.efi.getDatabaseNode(ed.getEntityGroupName())
if (limit != null && databaseNode != null && "cursor".equals(databaseNode.attribute("offset-style"))) {
el = (EntityListImpl) eli.getPartialList(offset != null ? offset : 0, limit, true)
} else {
el = (EntityListImpl) eli.getCompleteList(true)
}

// register lock after because we can't before, don't know which records will be returned
if (forUpdate && !isViewEntity && efi.ecfi.transactionFacade.getUseLockTrack()) {
int elSize = el.size()
Expand Down Expand Up @@ -1446,9 +1445,7 @@ abstract class EntityFindBase implements EntityFind {

this.useCache(false)
long totalUpdated = 0
EntityListIterator eli = (EntityListIterator) null
try {
eli = iterator()
iterator().withCloseable ({eli ->
EntityValue value
while ((value = eli.next()) != null) {
value.putAll(fieldsToSet)
Expand All @@ -1458,9 +1455,7 @@ abstract class EntityFindBase implements EntityFind {
totalUpdated++
}
}
} finally {
if (eli != null) eli.close()
}
})
return totalUpdated
}

Expand Down Expand Up @@ -1495,33 +1490,27 @@ abstract class EntityFindBase implements EntityFind {
}
} else {
this.resultSetConcurrency(ResultSet.CONCUR_UPDATABLE)
EntityListIterator eli = (EntityListIterator) null
try {
eli = iterator()
iterator().withCloseable ({eli->

while (eli.next() != null) {
// no longer need to clear cache, eli.remove() does that
eli.remove()
totalDeleted++
}
} finally {
if (eli != null) eli.close()
}
})
}
return totalDeleted
}

@Override
void extract(SimpleEtl etl) {
EntityListIterator eli = iterator()
try {
try (EntityListIterator eli = iterator()) {
EntityValue ev
while ((ev = eli.next()) != null) {
etl.processEntry(ev)
}
} catch (StopException e) {
logger.warn("EntityFind extract stopped on: " + (e.getCause()?.toString() ?: e.toString()))
} finally {
eli.close()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ public EntityValueBase currentEntityValueBase() {
} catch (SQLException e) {
throw new EntityException("Error getting all results", e);
} finally {
//TODO: Remove closeAfter with respect to try-with-resource implementation
if (closeAfter) close();
}
}
Expand Down
10 changes: 3 additions & 7 deletions framework/src/test/groovy/EntityNoSqlCrud.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -121,23 +121,19 @@ class EntityNoSqlCrud extends Specification {

def "ELI find TestNoSqlEntity"() {
when:
EntityListIterator eli
EntityList partialEl = null
EntityValue first = null
try {
eli = ec.entity.find("moqui.test.TestNoSqlEntity")
.orderBy("-testNumberInteger").iterator()
try (EntityListIterator eli = ec.entity.find("moqui.test.TestNoSqlEntity")
.orderBy("-testNumberInteger").iterator()) {


partialEl = eli.getPartialList(0, 100, false)

eli.beforeFirst()
first = eli.next()
} catch (Exception e) {
logger.error("partialEl error", e)
} finally {
if (eli != null) eli.close()
}

// logger.warn("partialEl.size() ${partialEl.size()} first value ${first}")

then:
Expand Down
Loading