the thread scope cannot be modified from outside the owner thread

Description

Not sure how I am getting this error in my thread log.

"ERROR","cfthread-594303","10/25/2020","17:39:59","cfthread-594303","the thread scope cannot be modified from outside the owner thread;the thread scope cannot be modified from outside the owner thread;lucee.runtime.exp.ApplicationException: the thread scope cannot be modified from outside the owner

thread
at lucee.runtime.thread.ThreadsImpl.errorOutside(ThreadsImpl.java:395)
at lucee.runtime.thread.ThreadsImpl.set(ThreadsImpl.java:271)
at lucee.runtime.type.util.StructSupport.set(StructSupport.java:262)
at lucee.runtime.util.VariableUtilImpl.set(VariableUtilImpl.java:424)
at lucee.runtime.PageContextImpl.set(PageContextImpl.java:1458)
at bay.s3_cfc$cf$133.threadCall(/bay/s3.cfc:163)
at lucee.runtime.thread.ChildThreadImpl.execute(ChildThreadImpl.java:203)
at lucee.runtime.thread.ChildThreadImpl.run(ChildThreadImpl.java:145)
"

line 163 = thread.result = local.s3.putObject(bucket=attributes.bucket, objectkey=attributes.path_to_resource, filecontent=local.body, contenttype=local.contentType);

function upload(resource, file, string contents = '', boolean waitForComplete = true){
if(IsSimpleValue(arguments.file)){
local.files = [arguments.file];
}

if(IsArray(arguments.file)){
local.files = Duplicate(arguments.file);
}

local.ret = StructNew();

local.threads = StructNew();

local.parse = parseResource(arguments.resource);

local.p_endpoint = local.parse.endpoint;
local.p_bucket = local.parse.bucket;
local.p_resource = local.parse.resource;

for(local.file in local.files){
local.threadname = 'thread_' & replace(createUUID(), '-', '', 'ALL');

local.threads[local.threadname] = local.file;

if(local.file contains '/'){
local.path_to_resource = '#local.p_resource#/#listlast(local.file, "/")#';
}else{
local.path_to_resource = '#local.p_resource#/#listlast(local.file, "\")#';
}

thread action="run", name="#local.threadname#", file="#local.file#", endpoint="#local.p_endpoint#", path_to_resource="#local.path_to_resource#", bucket="#local.p_bucket#", contents="#arguments.contents#" {
if(left(attributes.file, 4) eq 'http'){
http result="local.GET", method="GET", url="#attributes.file#", getasbinary="yes" {}

local.body = local.GET.filecontent;
}else{
if(attributes.contents eq ''){
local.body = fileReadBinary(attributes.file);
}else{
local.body = attributes.contents;
}
}

local.s3 = this.aws[attributes.endpoint].s3;

thread.attributes = attributes;

switch(listLast(attributes.path_to_resource, '.')){
case 'jpg':
local.contentType = 'image/jpeg';

break;

case 'gif':
local.contentType = 'image/gif';

break;

case 'png':
local.contentType = 'image/png';

break;

case 'pdf':
local.contentType = 'application/pdf';

break;

case 'html':
local.contentType = 'text/html';

break;

default:
local.contentType = '';

break;
}

thread.result = local.s3.putObject(bucket=attributes.bucket, objectkey=attributes.path_to_resource, filecontent=local.body, contenttype=local.contentType);

thread.status_code = thread.result.statusCode;
}
}

if(arguments.waitForComplete){
threadJoin(StructKeyList(local.threads));

for(local.thread in local.threads){
local.ret[local.threads[local.thread]] = evaluate(local.thread);
}

return local.ret;
}else{
return true;
}
}

Environment

None

Activity

Show:
Pothys - MitrahSoft
November 20, 2020, 10:49 AM

,
I've checked this ticket and couldn't able to reproduce the exact issue with your sample code. So, please add an example for reproduce the error if possible. It'll help to improve the status of the ticket.

Assignee

Pothys - MitrahSoft

Reporter

Lyle Karstensen

Priority

Critical

Labels

Fix versions

None

Affects versions

Configure