Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 6 additions & 5 deletions api/src/org/labkey/api/data/CachedResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@
package org.labkey.api.data;

import org.apache.commons.beanutils.ConvertUtils;
import java.lang.ref.Cleaner;
import org.apache.commons.collections4.IteratorUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.collections.RowMap;
import org.labkey.api.dataiterator.DataIterator;
import org.labkey.api.miniprofiler.MiniProfiler;
import org.labkey.api.settings.AppProps;
import org.labkey.api.util.ExceptionUtil;
import org.labkey.api.util.MemTracker;
import org.labkey.api.util.ResultSetUtil;
import org.labkey.api.util.logging.LogHelper;
import org.labkey.api.view.HttpView;
import org.labkey.api.view.ViewServlet;

import java.io.InputStream;
import java.io.Reader;
import java.lang.ref.Cleaner;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.Array;
Expand Down Expand Up @@ -68,7 +69,7 @@
*/
public class CachedResultSet implements ResultSet, TableResultSet
{
private static final Logger _log = LogManager.getLogger(CachedResultSet.class);
private static final Logger _log = LogHelper.getLogger(CachedResultSet.class, "Unclosed CachedResultSets");

// metadata
private final ResultSetMetaData _md;
Expand Down Expand Up @@ -173,12 +174,12 @@ private void close()

String url = null;
String threadName = null;
if (MiniProfiler.isCollectTroubleshootingStackTraces())
if (AppProps.getInstance().isDevMode()) //MiniProfiler.isCollectTroubleshootingStackTraces()) // TODO: Restore check before 26.3
{
// Stash stack trace that created this CachedRowSet
if (null == stackTrace)
{
stackTrace = MiniProfiler.getTroubleshootingStackTrace();
stackTrace = MiniProfiler.getTroubleshootingStackTraceUnconditionally(); // TODO: Switch to conditional method before 26.3
}

threadName = Thread.currentThread().getName();
Expand Down
29 changes: 17 additions & 12 deletions api/src/org/labkey/api/miniprofiler/MiniProfiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,20 +269,25 @@ public static boolean isCollectTroubleshootingStackTraces()
@Nullable
public static StackTraceElement[] getTroubleshootingStackTrace()
{
if (isCollectTroubleshootingStackTraces())
return isCollectTroubleshootingStackTraces() ? getTroubleshootingStackTraceUnconditionally() : null;
}

/**
* @return the stack of the calling thread regardless of the state of the "enable stack traces" setting.
*/
@NotNull
public static StackTraceElement[] getTroubleshootingStackTraceUnconditionally()
{
StackTraceElement[] fullStack = Thread.currentThread().getStackTrace();
if (fullStack.length > 0)
{
StackTraceElement[] fullStack = Thread.currentThread().getStackTrace();
if (fullStack.length > 0)
{
// Automatically omit this method from the stack
int callerFramesToOmit = 2;
StackTraceElement[] result = new StackTraceElement[fullStack.length - callerFramesToOmit];
System.arraycopy(fullStack, 1, result, 0, result.length);
return result;
}
return fullStack;
// Automatically omit this method from the stack
int callerFramesToOmit = 2;
StackTraceElement[] result = new StackTraceElement[fullStack.length - callerFramesToOmit];
System.arraycopy(fullStack, 1, result, 0, result.length);
return result;
}
return null;
return fullStack;
}

/** This setting will be retained only for the current instance of the web app. Once the server is restarted, it will default to false again */
Expand Down
12 changes: 6 additions & 6 deletions devtools/src/org/labkey/devtools/TestController.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.labkey.api.action.SimpleResponse;
import org.labkey.api.action.SimpleViewAction;
import org.labkey.api.action.SpringActionController;
import org.labkey.api.collections.LabKeyCollectors;
import org.labkey.api.data.Container;
import org.labkey.api.data.ContainerManager;
import org.labkey.api.mcp.AbstractAgentAction;
Expand Down Expand Up @@ -1292,7 +1291,7 @@ public void addNavTrail(NavTree root)
public static class ChatAction extends SimpleViewAction<Object>
{
@Override
public ModelAndView getView(Object o, BindException errors) throws Exception
public ModelAndView getView(Object o, BindException errors)
{
if (null == McpService.get() || !McpService.get().isReady())
return HtmlView.of("Service is not ready yet.");
Expand Down Expand Up @@ -1331,14 +1330,14 @@ public static class PopulateVectorStoreAction extends ConfirmAction<Object>
AtomicInteger count = new AtomicInteger();

@Override
public ModelAndView getConfirmView(Object o, BindException errors) throws Exception
public ModelAndView getConfirmView(Object o, BindException errors)
{
var db = FileUtil.getTempDirectoryFileLike().resolveChild("VectorStore.database");
HtmlStringBuilder message = HtmlStringBuilder.of();
message.append("This will add the contents of /Documention wikis to the vector store.").append(HtmlString.BR);
message.append("This may take a few minutes.");
if (db.exists())
message.unsafeAppend("<p/><p/>").append("I see a vector store file already exists. Just FYI.");
message.unsafeAppend("<p/><p/>").append("I see a vector store file already exists. Just FYI.");
return new HtmlView(message);
}

Expand All @@ -1355,20 +1354,21 @@ public void validateCommand(Object o, Errors errors)


// not usually used but some actions return views that close the current window etc...
@Override
public ModelAndView getSuccessView(Object form)
{
return HtmlView.of(count.get() + " documents added to vector store");
}

@Override
public boolean handlePost(Object o, BindException errors) throws Exception
public boolean handlePost(Object o, BindException errors)
{
Container documentsContainer = ContainerManager.getForPath("/Documentation");
if (null == documentsContainer)
throw new NotFoundException();
VectorStore vs = McpService.get().getVectorStore();
if (null == vs)
throw new NotFoundException();
throw new NotFoundException("/Documentation project was not found");

ActionURL wikiBase = new ActionURL("wiki","page",documentsContainer);

Expand Down